Exemple #1
0
        protected void btnExecute_Click(object sender, EventArgs e)
        {
            string errorMessage = string.Empty;

            bool result = EnvironmentChecks.CheckSqlServer(txtServer.Text, txtUsername.Text, txtPassword.Text, txtDatabase.Text, out errorMessage);

            lMessages.Text = result.ToString() + " - " + errorMessage;
        }
Exemple #2
0
        public AppWithEnvironmentChecks()
        {
            // Register an IEnvironmentCheck object
            EnvironmentChecks.Register(new FileExistsCheck("settings.json"));

            // or declaratively say a file should exist (this is just syntactic sugar)
            EnvironmentChecks.FileShouldExist("settings.json");

            // or do it manually w/ a lambda
            EnvironmentChecks.Register("settings.json can be found", () =>
            {
                if (!File.Exists("settings.json"))
                {
                    throw new Exception("File cannot be found");
                }
            });

            // Or register a check type
            EnvironmentChecks.Register <CustomCheck>();

            // The concrete Store class exposes IEnvironmentCheck
            Services.AddTransient <IStore, Store>();
        }