Пример #1
0
        public SystemSettingsSwitcherSettings(IObjectData data) : base(data)
        {
            // prepare settings
            bool enableSystemSettingsSwitch = Defaults.EnableSystemSettingsSwitch;
            ActualProxySettings actualProxy = null;

            if (data != null)
            {
                // get settings from data
                enableSystemSettingsSwitch = data.GetBooleanValue(SettingNames.EnableSystemSettingsSwitch, enableSystemSettingsSwitch);
                // Note that ActualProxy should not be empty but null if the settings do not exist.
                actualProxy = data.GetObjectValue(SettingNames.ActualProxy, actualProxy, this.CreateActualProxySettings);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.EnableSystemSettingsSwitch = enableSystemSettingsSwitch;
                this.ActualProxy = actualProxy;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
Пример #2
0
        public CredentialSettings(IObjectData data) : base(data)
        {
            // prepare settings
            string endPoint = Defaults.EndPoint;
            string userName = Defaults.UserName;
            string password = string.Empty;
            CredentialPersistence persistence = Defaults.Persistence;
            bool enableAssumptionMode         = Defaults.EnableAssumptionMode;

            if (data != null)
            {
                // get settings from data
                endPoint             = data.GetStringValue(SettingNames.EndPoint, endPoint);
                userName             = data.GetStringValue(SettingNames.UserName, userName);
                password             = data.GetValue(SettingNames.ProtectedPassword, password, ExtractPasswordValue);
                persistence          = (CredentialPersistence)data.GetEnumValue(SettingNames.Persistence, persistence, typeof(CredentialPersistence));
                enableAssumptionMode = data.GetBooleanValue(SettingNames.EnableAssumptionMode, enableAssumptionMode);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.EndPoint             = endPoint;
                this.UserName             = userName;
                this.Password             = password;
                this.Persistence          = persistence;
                this.EnableAssumptionMode = enableAssumptionMode;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
        public GUIForWindowsGUISettings(IObjectData data) : base(data)
        {
            // prepare settings
            bool chaseLastLog             = Defaults.ChaseLastLog;
            MainWindowSettings mainWindow = null;

            if (data != null)
            {
                // get settings from data
                chaseLastLog = data.GetBooleanValue(SettingNames.ChaseLastLog, chaseLastLog);
                mainWindow   = data.GetObjectValue(SettingNames.MainWindow, mainWindow, this.CreateMainWindowSettings);
            }
            if (mainWindow == null)
            {
                mainWindow = CreateMainWindowSettings(null);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.ChaseLastLog = chaseLastLog;
                this.mainWindow   = mainWindow;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
Пример #4
0
        public GUISettings(IObjectData data) : base(data)
        {
            // prepare settings
            bool start          = Defaults.Start;
            int  resumeTryCount = Defaults.ResumeTryCount;
            int  resumeDelay    = Defaults.ResumeDelay;
            int  resumeInterval = Defaults.ResumeInterval;

            if (data != null)
            {
                // get settings from data
                start          = data.GetBooleanValue(SettingNames.Start, start);
                resumeTryCount = data.GetInt32Value(SettingNames.ResumeTryCount, resumeTryCount);
                resumeDelay    = data.GetInt32Value(SettingNames.ResumeDelay, resumeDelay);
                resumeInterval = data.GetInt32Value(SettingNames.ResumeInterval, resumeInterval);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.Start          = start;
                this.ResumeTryCount = resumeTryCount;
                this.ResumeDelay    = resumeDelay;
                this.ResumeInterval = resumeInterval;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
Пример #5
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;
        }
Пример #6
0
        public SystemSettingsForWindows(IObjectData data) : base(data)
        {
            // prepare settings
            string autoConfigURL = null;
            int?   proxyEnable   = null;
            string proxyServer   = null;
            string proxyOverride = null;
            bool   autoDetect    = false;
            string httpProxyEnvironmentVariable  = null;
            string httpsProxyEnvironmentVariable = null;

            if (data != null)
            {
                // get settings from data
                autoConfigURL = data.GetStringValue(SettingNames.AutoConfigURL, null);
                proxyEnable   = data.GetValue(SettingNames.ProxyEnable, ObjectDataExtension.ExtractInt32Value);
                proxyServer   = data.GetStringValue(SettingNames.ProxyServer, null);
                proxyOverride = data.GetStringValue(SettingNames.ProxyOverride, null);
                autoDetect    = data.GetBooleanValue(SettingNames.AutoDetect, false);
                httpProxyEnvironmentVariable  = data.GetStringValue(SettingNames.HttpProxyEnvironmentVariable, null);
                httpsProxyEnvironmentVariable = data.GetStringValue(SettingNames.HttpsProxyEnvironmentVariable, null);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value
                this.AutoConfigURL = autoConfigURL;
                this.ProxyEnable   = proxyEnable;
                this.ProxyServer   = proxyServer;
                this.ProxyOverride = proxyOverride;
                this.AutoDetect    = autoDetect;
                this.HttpProxyEnvironmentVariable  = httpProxyEnvironmentVariable;
                this.HttpsProxyEnvironmentVariable = httpsProxyEnvironmentVariable;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }