Пример #1
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;
        }
Пример #2
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;
        }
Пример #3
0
        public ActualProxySettings(IObjectData data) : base(data)
        {
            // prepare settings
            string host = Defaults.Host;
            int    port = Defaults.Port;
            string configurationScript = Defaults.ConfigurationScript;

            if (data != null)
            {
                // get settings from data
                configurationScript = data.GetStringValue(SettingNames.ConfigurationScript, configurationScript);
                host = data.GetStringValue(SettingNames.Host, string.IsNullOrEmpty(configurationScript)? host: null);
                port = data.GetInt32Value(SettingNames.Port, port);
            }

            // set settings
            try {
                // may throw ArgumentException for an invalid value

                // Note that non-empty value should be set first,
                // because an ArgumentNullException will be thrown
                // if both this.Host and this.this.ConfigurationScript are null.
                if (string.IsNullOrEmpty(configurationScript))
                {
                    this.Host = host;
                    this.ConfigurationScript = configurationScript;
                }
                else
                {
                    this.ConfigurationScript = configurationScript;
                    this.Host = host;
                }
                this.Port = port;
            } catch (Exception exception) {
                throw new FormatException(exception.Message);
            }

            return;
        }
Пример #4
0
        public SystemSettingsSwitcherForWindowsSettings(IObjectData data) : base(data)
        {
            // prepare settings
            string proxyOverride = Defaults.ProxyOverride;

            if (data != null)
            {
                // get settings from data
                proxyOverride = data.GetStringValue(SettingNames.ProxyOverride, proxyOverride);
            }

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

            return;
        }