예제 #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 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;
        }