Exemplo n.º 1
0
        public ProxySettings(IObjectData data) : base(data)
        {
            // prepare settings
            ListenerSettings mainListener = null;
            IEnumerable <ListenerSettings> additionalListeners = null;
            int retryCount = Defaults.RetryCount;

            if (data != null)
            {
                // get settings from data
                mainListener        = data.GetObjectValue(SettingNames.MainListener, mainListener, CreateListenerSettings);
                additionalListeners = data.GetObjectArrayValue(SettingNames.AdditionalListeners, additionalListeners, CreateListenerSettings);
                retryCount          = data.GetInt32Value(SettingNames.RetryCount, retryCount);
            }
            if (mainListener == null)
            {
                mainListener = Defaults.CreateDefaultMainListener();
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.MainListener        = mainListener;
                this.AdditionalListeners = additionalListeners;
                this.RetryCount          = retryCount;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
Exemplo n.º 2
0
        public CommandSettings(IObjectData data) : base(data)
        {
            // prepare settings
            int         initialSetupLevel = Defaults.InitialSetupLevel;
            TraceLevel  logLevel          = Defaults.LogLevel;
            CultureInfo culture           = null;
            bool        noLogo            = Defaults.NoLogo;

            CredentialSettings[]           credentials            = null;
            SystemSettingsSwitcherSettings systemSettingsSwitcher = null;
            GUISettings   gui   = null;
            ProxySettings proxy = null;

            if (data != null)
            {
                // get settings from data
                initialSetupLevel      = data.GetInt32Value(SettingNames.InitialSetupLevel, Defaults.InitialSetupLevel);
                logLevel               = (TraceLevel)data.GetEnumValue(SettingNames.LogLevel, logLevel, typeof(TraceLevel));
                culture                = data.GetValue(SettingNames.Culture, culture, ExtractCultureInfoValue);
                noLogo                 = data.GetBooleanValue(SettingNames.NoLogo, noLogo);
                credentials            = data.GetObjectArrayValue(SettingNames.Credentials, credentials, CreateCredentialSettings);
                systemSettingsSwitcher = data.GetObjectValue(SettingNames.SystemSettingsSwitcher, systemSettingsSwitcher, this.CreateSystemSettingsSwitcherSettings);
                proxy = data.GetObjectValue(SettingNames.Proxy, proxy, this.CreateProxySettings);
                gui   = data.GetObjectValue(SettingNames.GUI, gui, this.CreateGUISettings);
            }
            if (systemSettingsSwitcher == null)
            {
                // SystemSettingsSwitcher cannot be null
                systemSettingsSwitcher = CreateSystemSettingsSwitcherSettings(null);
            }
            if (proxy == null)
            {
                // Proxy cannot be null
                proxy = CreateProxySettings(null);
            }
            if (gui == null)
            {
                // GUI cannot be null
                gui = CreateGUISettings(null);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.InitialSetupLevel      = initialSetupLevel;
                this.LogLevel               = logLevel;
                this.Culture                = culture;
                this.NoLogo                 = noLogo;
                this.Credentials            = credentials;
                this.SystemSettingsSwitcher = systemSettingsSwitcher;
                this.Proxy = proxy;
                this.GUI   = gui;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }