Esempio n. 1
0
        protected override void Execute(IOutputAppender outputAppender)
        {
            var environmentSettings = ResolveEnvironmentSettings(outputAppender);

            if (string.Compare(AffiliateApplicationName, environmentSettings.ApplicationName, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new InvalidOperationException(
                          $"{nameof(AffiliateApplication)} name '{AffiliateApplicationName}' does not match {environmentSettings.GetType().Name} one '{environmentSettings.ApplicationName}'.");
            }

            if (environmentSettings is IProvideSsoSettings ssoSettingProvider)
            {
                outputAppender.WriteInformation($"SSO {nameof(AffiliateApplication)} '{AffiliateApplicationName}''s {nameof(ConfigStore)} is being updated...");

                var affiliateApplication = AffiliateApplication.FindByName(AffiliateApplicationName)
                                           ?? throw new InvalidOperationException($"SSO {nameof(AffiliateApplication)} '{AffiliateApplicationName}' was not found.");
                outputAppender.WriteVerbose($"Loading existing {nameof(ConfigStore)}.");
                var configStore = affiliateApplication.ConfigStores.Default;
                ssoSettingProvider.SsoSettings.ForEach(
                    kvp => {
                    outputAppender.WriteVerbose($"Adding or updating property '{kvp.Key}' to {nameof(ConfigStore)}.");
                    configStore.Properties[kvp.Key] = kvp.Value;
                });
                outputAppender.WriteVerbose($"Saving {nameof(ConfigStore)} changes.");
                configStore.Save();

                outputAppender.WriteInformation($"SSO {nameof(AffiliateApplication)} '{AffiliateApplicationName}''s {nameof(ConfigStore)} has been updated.");
            }
            else
            {
                outputAppender.WriteInformation(
                    $"SSO {nameof(AffiliateApplication)} '{AffiliateApplicationName}''s {nameof(ConfigStore)} update is being skipped as {environmentSettings.GetType().Name} does not provide any SSO Settings.");
            }
        }
Esempio n. 2
0
        private Type ResolveEnvironmentSettingOverridesType(IOutputAppender outputAppender)
        {
            outputAppender.WriteInformation($"Resolving EnvironmentSettingOverridesType '{EnvironmentSettingOverridesTypeName}'...");
            var environmentSettingOverridesType = Type.GetType(EnvironmentSettingOverridesTypeName, true);

            outputAppender.WriteInformation($"Resolved EnvironmentSettingOverridesType in assembly '{environmentSettingOverridesType.Assembly.Location}'.");
            return(environmentSettingOverridesType);
        }
Esempio n. 3
0
        private IEnvironmentSettings ResolveEnvironmentSettings(IOutputAppender outputAppender)
        {
            outputAppender.WriteInformation($"Resolving {nameof(IEnvironmentSettings)}-derived singleton in assembly '{EnvironmentSettingsAssemblyFilePath}'...");
            var environmentSettings = AssemblyLoader.Load(EnvironmentSettingsAssemblyFilePath).GetEnvironmentSettingsSingleton(true);

            outputAppender.WriteInformation(
                $"Resolved {nameof(IEnvironmentSettings)}-derived singleton '{environmentSettings.GetType().AssemblyQualifiedName}' in assembly '{environmentSettings.GetType().Assembly.Location}'.");
            return(environmentSettings);
        }