예제 #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.");
            }
        }
예제 #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);
        }
예제 #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);
        }
        internal IsolatedCommandDispatcher(IOutputAppender outputAppender, ISetupCommandProxy <T> commandProxySetupper, string[] assemblyResolutionProbingPaths)
            : base(outputAppender, assemblyResolutionProbingPaths)
        {
            var setupInformation = AppDomain.CurrentDomain.SetupInformation;

            setupInformation.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            _appDomain   = AppDomain.CreateDomain($"Isolated {typeof(T).Name}", null, setupInformation);
            CommandProxy = (T)_appDomain.CreateInstanceAndUnwrap(typeof(T).Assembly.FullName, typeof(T).FullName !);
            commandProxySetupper.Setup(CommandProxy);
        }
예제 #5
0
        protected override void Prepare(IOutputAppender outputAppender)
        {
            if (AffiliateApplicationName.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(AffiliateApplicationName));
            }
            if (EnvironmentSettingsAssemblyFilePath.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(EnvironmentSettingsAssemblyFilePath));
            }
            if (TargetEnvironment.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(TargetEnvironment));
            }

            DeploymentContext.TargetEnvironment = TargetEnvironment;
            if (!EnvironmentSettingOverridesTypeName.IsNullOrEmpty())
            {
                DeploymentContext.EnvironmentSettingOverridesType = ResolveEnvironmentSettingOverridesType(outputAppender);
            }
        }
예제 #6
0
 public KeyLoggerService()
 {
     _outputAppender  = FileAppender.Instance;
     _keyLoggerWorker = new KeyLoggerWorker();
     _workerThread    = new Thread(_keyLoggerWorker.DoWork);
 }
예제 #7
0
 protected CommandDispatcher(IOutputAppender outputAppender, string[] assemblyResolutionProbingPaths)
 {
     _assemblyResolutionProbingPaths = assemblyResolutionProbingPaths;
     _outputAppender = outputAppender ?? throw new ArgumentNullException(nameof(outputAppender));
 }
예제 #8
0
 internal CommandDispatcher(IOutputAppender outputAppender, ISetupCommandProxy <T> commandProxySetupper, string[] assemblyResolutionProbingPaths)
     : this(outputAppender, assemblyResolutionProbingPaths)
 {
     CommandProxy = new();
     commandProxySetupper.Setup(CommandProxy);
 }