Example #1
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ExchangeSettings exchangeSettings = (ExchangeSettings)base.PrepareDataObject();

            if (base.HasErrors)
            {
                return(null);
            }
            if (!this.Force && !SetExchangeSettings.IsSchemaRegistered(base.Name))
            {
                base.WriteError(new ExchangeSettingsInvalidSchemaException(base.Name), ErrorCategory.InvalidOperation, null);
            }
            exchangeSettings.SetId(this.ConfigurationSession, base.Name);
            exchangeSettings.InitializeSettings();
            TaskLogger.LogExit();
            return(exchangeSettings);
        }
Example #2
0
        protected override void WriteResult(IConfigurable dataObject)
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObject.Identity,
                dataObject
            });
            ExchangeSettings         exchangeSettings         = (ExchangeSettings)dataObject;
            ConfigDiagnosticArgument configDiagnosticArgument = new ConfigDiagnosticArgument(this.DiagnosticArgument);

            if (configDiagnosticArgument.HasArgument("force"))
            {
                this.Force = true;
            }
            if (string.IsNullOrEmpty(this.ConfigName) && configDiagnosticArgument.HasArgument("configname"))
            {
                this.ConfigName = configDiagnosticArgument.GetArgument <string>("configname");
            }
            if (exchangeSettings != null)
            {
                ConfigSchemaBase schema = null;
                if (SetExchangeSettings.IsSchemaRegistered(exchangeSettings.Identity.ToString()))
                {
                    schema = SetExchangeSettings.GetRegisteredSchema(exchangeSettings.Identity.ToString(), this.Force, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
                if (exchangeSettings.Groups != null)
                {
                    foreach (SettingsGroup settingsGroup in exchangeSettings.Groups)
                    {
                        try
                        {
                            settingsGroup.Validate(schema, null);
                        }
                        catch (ConfigurationSettingsException ex)
                        {
                            base.WriteWarning(ex.Message);
                        }
                    }
                }
                this.ProcessDiagnostic(exchangeSettings, configDiagnosticArgument, schema);
            }
            base.WriteResult(exchangeSettings);
            TaskLogger.LogExit();
        }