예제 #1
0
        private static void AddPropertySettingsFromConfig(Type baseType, bool fAnonEnabled, bool hasLowTrust, ProfilePropertySettingsCollection settingsCollection, string groupName)
        {
            foreach (ProfilePropertySettings pps in settingsCollection)
            {
                string name = (groupName != null) ? (groupName + "." + pps.Name) : pps.Name;
                if (baseType != typeof(ProfileBase) && s_Properties[name] != null)
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Profile_property_already_added), null, pps.ElementInformation.Properties["name"].Source, pps.ElementInformation.Properties["name"].LineNumber);
                }

                try {
                    if (pps.TypeInternal == null)
                    {
                        pps.TypeInternal = ResolvePropertyType(pps.Type);
                    }
                }
                catch (Exception e) {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Profile_could_not_create_type, e.Message), e, pps.ElementInformation.Properties["type"].Source, pps.ElementInformation.Properties["type"].LineNumber);
                }
                if (!fAnonEnabled)
                {
                    bool fAllowAnonymous = pps.AllowAnonymous;
                    if (fAllowAnonymous)
                    {
                        throw new ConfigurationErrorsException(SR.GetString(SR.Annoymous_id_module_not_enabled, pps.Name), pps.ElementInformation.Properties["allowAnonymous"].Source, pps.ElementInformation.Properties["allowAnonymous"].LineNumber);
                    }
                }
                if (hasLowTrust)
                {
                    SetProviderForProperty(pps);
                }
                else
                {
                    pps.ProviderInternal = null;
                }
                // Providers that use NetDataContractSerialzier do not require Serializable attributes any longer, only enforce this for the SqlProfileProvider
                bool requireSerializationCheck = pps.ProviderInternal == null || pps.ProviderInternal.GetType() == typeof(SqlProfileProvider);
                if (requireSerializationCheck && pps.SerializeAs == SerializationMode.Binary && !pps.TypeInternal.IsSerializable)
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Property_not_serializable, pps.Name), pps.ElementInformation.Properties["serializeAs"].Source, pps.ElementInformation.Properties["serializeAs"].LineNumber);
                }

                SettingsAttributeDictionary settings = new SettingsAttributeDictionary();
                settings.Add("AllowAnonymous", pps.AllowAnonymous);
                if (!string.IsNullOrEmpty(pps.CustomProviderData))
                {
                    settings.Add("CustomProviderData", pps.CustomProviderData);
                }
                SettingsProperty sp = new SettingsProperty(name, pps.TypeInternal, pps.ProviderInternal, pps.ReadOnly, pps.DefaultValue, (SettingsSerializeAs)pps.SerializeAs, settings, false, true);
                s_Properties.Add(sp);
            }
        }
예제 #2
0
        public void AddPropertySetting(string name, Type type, object defaultValue)
        {
            // Only allow settings to be added during initialization
            if (!_initialized)
            {
                string providerName = "LocalFileSettingsProvider";

                SettingsAttributeDictionary attributes = new SettingsAttributeDictionary();
                UserScopedSettingAttribute  attr       = new UserScopedSettingAttribute();
                attributes.Add(attr.TypeId, attr);

                var prop = new SettingsProperty(
                    new SettingsProperty(name
                                         , type
                                         , cairoSettings.Providers[providerName]
                                         , false
                                         , defaultValue
                                         , SettingsSerializeAs.String
                                         , attributes
                                         , false
                                         , false));

                cairoSettings.Properties.Add(prop);
                cairoSettings.Save();
                cairoSettings.Reload();
            }
        }
        public void GetUserScopedPropertyValues()
        {
            SettingsAttributeDictionary dict = new SettingsAttributeDictionary();
            UserScopedSettingAttribute  attr = new UserScopedSettingAttribute();

            dict.Add(attr.GetType(), attr);

            LocalFileSettingsProvider prov = new LocalFileSettingsProvider();
            SettingsContext           ctx  = new SettingsContext();
            SettingsProperty          p    = new SettingsProperty("property",
                                                                  typeof(int),
                                                                  prov,
                                                                  false,
                                                                  10,
                                                                  SettingsSerializeAs.Binary,
                                                                  dict,
                                                                  false,
                                                                  false);
            SettingsPropertyCollection      col = new SettingsPropertyCollection();
            SettingsPropertyValueCollection vals;

            col.Add(p);

            prov.Initialize(null, null);

            vals = prov.GetPropertyValues(ctx, col);
            Assert.IsNotNull(vals, "A1");
            Assert.AreEqual(1, vals.Count, "A2");
        }
예제 #4
0
        public static string GetCredentialStoreServiceName()
        {
            var propertyName = "CredentialStoreServiceName";
            var providerName = "LocalFileSettingsProvider";

            if (!string.IsNullOrWhiteSpace(Settings.Default.Properties[propertyName]?.DefaultValue.ToString()))
            {
                var attributes = new SettingsAttributeDictionary();
                var attr       = new UserScopedSettingAttribute();
                attributes.Add(attr.TypeId, attr);

                var prop = new SettingsProperty(
                    propertyName,
                    typeof(string),
                    Settings.Default.Providers[providerName],
                    false, DefaultCredentialStoreServiceName, SettingsSerializeAs.String, attributes, false, false);

                Settings.Default.Properties.Add(prop);
                Settings.Default.Save();
                Settings.Default.Reload();
            }

            var result = Settings.Default.Properties[propertyName]?.ToString();

            if (result != null)
            {
                Console.WriteLine(result);
                return(result);
            }

            return(DefaultCredentialStoreServiceName);
        }
예제 #5
0
 private static void AddPropertySettingsFromConfig(Type baseType, bool fAnonEnabled, bool hasLowTrust, ProfilePropertySettingsCollection settingsCollection, string groupName)
 {
     foreach (ProfilePropertySettings settings in settingsCollection)
     {
         string name = (groupName != null) ? (groupName + "." + settings.Name) : settings.Name;
         if ((baseType != typeof(ProfileBase)) && (s_Properties[name] != null))
         {
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Profile_property_already_added"), null, settings.ElementInformation.Properties["name"].Source, settings.ElementInformation.Properties["name"].LineNumber);
         }
         try
         {
             if (settings.TypeInternal == null)
             {
                 settings.TypeInternal = ResolvePropertyType(settings.Type);
             }
         }
         catch (Exception exception)
         {
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Profile_could_not_create_type", new object[] { exception.Message }), exception, settings.ElementInformation.Properties["type"].Source, settings.ElementInformation.Properties["type"].LineNumber);
         }
         if (!fAnonEnabled && settings.AllowAnonymous)
         {
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Annoymous_id_module_not_enabled", new object[] { settings.Name }), settings.ElementInformation.Properties["allowAnonymous"].Source, settings.ElementInformation.Properties["allowAnonymous"].LineNumber);
         }
         if ((settings.SerializeAs == SerializationMode.Binary) && !settings.TypeInternal.IsSerializable)
         {
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Property_not_serializable", new object[] { settings.Name }), settings.ElementInformation.Properties["serializeAs"].Source, settings.ElementInformation.Properties["serializeAs"].LineNumber);
         }
         if (hasLowTrust)
         {
             SetProviderForProperty(settings);
         }
         else
         {
             settings.ProviderInternal = null;
         }
         SettingsAttributeDictionary attributes = new SettingsAttributeDictionary();
         attributes.Add("AllowAnonymous", settings.AllowAnonymous);
         if (!string.IsNullOrEmpty(settings.CustomProviderData))
         {
             attributes.Add("CustomProviderData", settings.CustomProviderData);
         }
         SettingsProperty property = new SettingsProperty(name, settings.TypeInternal, settings.ProviderInternal, settings.ReadOnly, settings.DefaultValue, (SettingsSerializeAs)settings.SerializeAs, attributes, false, true);
         s_Properties.Add(property);
     }
 }
예제 #6
0
        public PluginParameter(ePluginParameterID parameterName, T DefaultValue)
        {
            Seri.Log.Here().Verbose($"Настройка параметра {parameterName}");

            ID = parameterName;

            var ConstantName = parameterName.ToString();

            try
            {
                // Создаём параметр в настройках приложения
                if (Properties.Settings.Default.Properties[ConstantName] == null)
                {
                    // Создаём атрибут, что это пользовательский параметр
                    SettingsAttributeDictionary Attributes = new SettingsAttributeDictionary();
                    Attributes.Add(typeof(UserScopedSettingAttribute), new UserScopedSettingAttribute());

                    // Провайдер по умолчанию где будет сохранены настройки
                    var provider = Properties.Settings.Default.Providers["LocalFileSettingsProvider"];

                    // Создаем параметр
                    var ParamSettingsProperty = new SettingsProperty(ConstantName, typeof(T), provider, false, DefaultValue, SettingsSerializeAs.String, Attributes, false, false);
                    // Добавляем в настройки
                    Properties.Settings.Default.Properties.Add(ParamSettingsProperty);

                    // Создаём значение параметра
                    var ParamSettingsPropertyValue = new SettingsPropertyValue(ParamSettingsProperty);
                    // Добавляем в настройки
                    Properties.Settings.Default.PropertyValues.Add(ParamSettingsPropertyValue);

                    // Перезагружаем настройки. Так как мы добавили параметр, он теперь считается из файла настроек с диска (или возьмет значение по умолчанию)
                    Properties.Settings.Default.Reload();
                }

                Value = (T)Properties.Settings.Default[ConstantName];
            }
            catch (Exception ex)
            {
                Seri.LogException(ex);
                throw ex;
            }

            if (typeof(T) == typeof(string))
            {
                ParamterUIType = ePluginParameterUIType.Text;
            }
            else if (typeof(T) == typeof(bool))
            {
                ParamterUIType = ePluginParameterUIType.CheckBox;
            }
            else if (typeof(T) == typeof(int))
            {
                ParamterUIType = ePluginParameterUIType.Number;
            }

            Seri.Log.Here().Verbose($"Значение параметра {ID}: {Value}");
        }
예제 #7
0
        protected void CreateSettingProperty(string name, Type type, SettingsSerializeAs serializeAs, object defaultValue)
        {
            ApplicationSettings _applicationSettings = ApplicationSettings;

            if (_applicationSettings == null || _applicationSettings.DefaultProvider == null)
            {
                return;
            }

            SettingsProperty _settingsProperty = _applicationSettings.Properties[name];

            if (_settingsProperty != null)
            {
                return; // already present
            }

            SettingsAttributeDictionary _attributes = new SettingsAttributeDictionary();
            SettingAttribute            _attribute;

            switch (Scope)
            {
            case SettingScope.Application:
                // attribute = new ApplicationScopedSettingAttribute();
                throw new NotImplementedException();     // currently not supported

            case SettingScope.User:
                _attribute = new UserScopedSettingAttribute();
                break;

            default:
                return;
            }

            _attributes.Add(_attribute.TypeId, _attribute);

            _settingsProperty = new SettingsProperty(
                name,                                 // name
                type,                                 // type
                _applicationSettings.DefaultProvider, // settings provider
                false,                                // is readonly
                defaultValue,                         // default
                serializeAs,                          // serialize as
                _attributes,                          // attribute
                ThrowOnErrorDeserializing,            // throw on deserialization
                ThrowOnErrorSerializing);             // throw on serialization

            _applicationSettings.Properties.Add(_settingsProperty);
        }
예제 #8
0
        private static void AddToColl(ProfilePropertyMetadata p, SettingsPropertyCollection retColl, bool isAuthenticated)
        {
            string propName  = p.PropertyName;
            Type   propType  = Type.GetType(p.TypeName, false, true);
            bool   allowAnon = p.AllowAnonymousAccess;
            bool   readOnly  = p.IsReadOnly;

            if (!allowAnon && !isAuthenticated)
            {
                return;
            }

            SettingsSerializeAs         serializeAs = (SettingsSerializeAs)p.SerializeAs;
            SettingsAttributeDictionary dict        = new SettingsAttributeDictionary();

            dict.Add("AllowAnonymous", allowAnon);
            retColl.Add(new SettingsProperty(propName, propType, null, readOnly, p.DefaultValue, serializeAs, dict, true, true));
        }
예제 #9
0
 public static void EnsureProperties(FrameworkElement sender, Dictionary <FrameworkElement, DependencyProperty> savedElements)
 {
     foreach (FrameworkElement element in savedElements.Keys)
     {
         bool hasProperty =
             Properties.Settings.Default.Properties[sender.Name + "." + element.Name] != null;
         if (!hasProperty)
         {
             SettingsAttributeDictionary attributes = new SettingsAttributeDictionary();
             UserScopedSettingAttribute  attribute  = new UserScopedSettingAttribute();
             attributes.Add(attribute.GetType(), attribute);
             SettingsProperty property = new SettingsProperty(sender.Name + "." + element.Name,
                                                              savedElements[element].DefaultMetadata.DefaultValue.GetType(), Properties.Settings.Default.Providers["LocalFileSettingsProvider"], false, null, SettingsSerializeAs.String, attributes, true, true);
             Properties.Settings.Default.Properties.Add(property);
         }
     }
     Properties.Settings.Default.Reload();
 }
예제 #10
0
            private void AddMRUPropToSettings()
            {
                if (Settings?.Properties[propName] == null)
                {
                    object defValue = new StringCollection();

                    SettingsAttributeDictionary d = new SettingsAttributeDictionary();
                    d.Add(typeof(UserScopedSettingAttribute), new UserScopedSettingAttribute());
                    Settings.Properties.Add(new SettingsProperty(propName, typeof(StringCollection),
                                                                 Settings.Providers["LocalFileSettingsProvider"], false, defValue,
                                                                 SettingsSerializeAs.Xml, d, false, false));
                    Settings.Reload();
                    var conf = SettingsValue;
                    if (conf == null)
                    {
                        SettingsValue = new StringCollection();
                        Settings.Save();
                    }
                }
            }
예제 #11
0
        public void CreateSettingProperty(string name, Type type, SettingsSerializeAs serializeAs, object defaultValue)
        {
            var settingsProperty = Properties[name];

            if (settingsProperty != null)
            {
                return;
            }

            var attributes = new SettingsAttributeDictionary();
            var attribute  = new UserScopedSettingAttribute();

            attributes.Add(attribute.TypeId, attribute);

            settingsProperty = new SettingsProperty(
                name, type, DefaultProvider,
                false, defaultValue, serializeAs,
                attributes, false, false);

            Properties.Add(settingsProperty);
        }
예제 #12
0
        static SettingsProperty CreateSettingsProperty(PropertyInfo property)
        {
            SettingsProperty sp = new SettingsProperty(property.Name);

            Attribute [] attributes             = (Attribute [])property.GetCustomAttributes(false);
            SettingsAttributeDictionary attDict = new SettingsAttributeDictionary();
            bool defaultAssigned = false;

            sp.SerializeAs  = SettingsSerializeAs.ProviderSpecific;
            sp.PropertyType = property.PropertyType;
            sp.IsReadOnly   = false;
            sp.ThrowOnErrorDeserializing = false;
            sp.ThrowOnErrorSerializing   = true;

            for (int i = 0; i < attributes.Length; i++)
            {
                if (attributes [i] is DefaultSettingValueAttribute)
                {
                    sp.DefaultValue = ((DefaultSettingValueAttribute)attributes [i]).Value;
                    defaultAssigned = true;
                }
                else if (attributes [i] is SettingsProviderAttribute)
                {
                    Type providerType = HttpApplication.LoadType(((SettingsProviderAttribute)attributes [i]).ProviderTypeName);
                    sp.Provider = (SettingsProvider)Activator.CreateInstance(providerType);
                    sp.Provider.Initialize(null, null);
                }
                else if (attributes [i] is SettingsSerializeAsAttribute)
                {
                    sp.SerializeAs = ((SettingsSerializeAsAttribute)attributes [i]).SerializeAs;
                }
                else if (attributes [i] is SettingsAllowAnonymousAttribute)
                {
                    sp.Attributes ["AllowAnonymous"] = ((SettingsAllowAnonymousAttribute)attributes [i]).Allow;
                }
                else if (attributes [i] is CustomProviderDataAttribute)
                {
                    sp.Attributes ["CustomProviderData"] = ((CustomProviderDataAttribute)attributes [i]).CustomProviderData;
                }
                else if (attributes [i] is ApplicationScopedSettingAttribute ||
                         attributes [i] is UserScopedSettingAttribute ||
                         attributes [i] is SettingsDescriptionAttribute ||
                         attributes [i] is SettingAttribute)
                {
                    attDict.Add(attributes [i].GetType(), attributes [i]);
                }
            }

            if (sp.Provider == null)
            {
                sp.Provider = ProfileManager.Provider;
            }

            if (sp.Attributes ["AllowAnonymous"] == null)
            {
                sp.Attributes ["AllowAnonymous"] = false;
            }

            if (!defaultAssigned && sp.PropertyType == typeof(string) && sp.DefaultValue == null)
            {
                sp.DefaultValue = String.Empty;
            }

            return(sp);
        }
예제 #13
0
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        static private void InitializeStatic()
        {
            if (!ProfileManager.Enabled || s_Initialized)
            {
                if (s_InitializeException != null)
                {
                    throw s_InitializeException;
                }
                return;
            }
            lock (s_InitializeLock) {
                if (s_Initialized)
                {
                    if (s_InitializeException != null)
                    {
                        throw s_InitializeException;
                    }
                    return;
                }

                try {
                    ProfileSection config       = MTConfigUtil.GetProfileAppConfig();
                    bool           fAnonEnabled = (HostingEnvironment.IsHosted ? AnonymousIdentificationModule.Enabled : true);
                    Type           baseType     = ProfileBase.InheritsFromType;
                    bool           hasLowTrust  = HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Low);

                    s_Properties = new SettingsPropertyCollection();

                    // Step 0: Add all dynamic profile properties set programatically during PreAppStart
                    ProfileBase.AddPropertySettingsFromConfig(baseType, fAnonEnabled, hasLowTrust, ProfileManager.DynamicProfileProperties, null);

                    //////////////////////////////////////////////////////////////////////
                    // Step 1: Add Properties from the base class (if not ProfileBase)
                    if (baseType != typeof(ProfileBase))
                    {
                        //////////////////////////////////////////////////////////////////////
                        // Step 2: Construct a hashtable containing a list of all the property-names in the ProfileBase type
                        PropertyInfo[]      baseProps      = typeof(ProfileBase).GetProperties();
                        NameValueCollection baseProperties = new NameValueCollection(baseProps.Length);
                        foreach (PropertyInfo baseProp in baseProps)
                        {
                            baseProperties.Add(baseProp.Name, String.Empty);
                        }

                        //////////////////////////////////////////////////////////////////////
                        // Step 3: For each property in the derived class, add it to the s_Properties class.
                        PropertyInfo[] props = baseType.GetProperties();
                        foreach (PropertyInfo prop in props)
                        {
                            if (baseProperties[prop.Name] == null)   //not in the base class

                            {
                                ProfileProvider     prov           = hasLowTrust ? ProfileManager.Provider : null;
                                bool                readOnly       = false;
                                SettingsSerializeAs serializeAs    = SettingsSerializeAs.ProviderSpecific;
                                string              defaultValue   = String.Empty;
                                bool                allowAnonymous = false;
                                string              customData     = null;

                                //////////////////////////////////////////////////////////////////////
                                // Step 4: For the property, get the attributes
                                Attribute[] attribs = Attribute.GetCustomAttributes(prop, true);

                                foreach (Attribute attrib in attribs)
                                {
                                    if (attrib is SettingsSerializeAsAttribute)
                                    {
                                        serializeAs = ((SettingsSerializeAsAttribute)attrib).SerializeAs;
                                    }
                                    else if (attrib is SettingsAllowAnonymousAttribute)
                                    {
                                        allowAnonymous = ((SettingsAllowAnonymousAttribute)attrib).Allow;
                                        if (!fAnonEnabled && allowAnonymous)
                                        {
                                            throw new ConfigurationErrorsException(SR.GetString(SR.Annoymous_id_module_not_enabled, prop.Name), config.ElementInformation.Properties["inherits"].Source, config.ElementInformation.Properties["inherits"].LineNumber);
                                        }
                                    }
                                    else if (attrib is System.ComponentModel.ReadOnlyAttribute)
                                    {
                                        readOnly = ((System.ComponentModel.ReadOnlyAttribute)attrib).IsReadOnly;
                                    }
                                    else if (attrib is DefaultSettingValueAttribute)
                                    {
                                        defaultValue = ((DefaultSettingValueAttribute)attrib).Value;
                                    }
                                    else if (attrib is CustomProviderDataAttribute)
                                    {
                                        customData = ((CustomProviderDataAttribute)attrib).CustomProviderData;
                                    }
                                    else if (hasLowTrust && attrib is ProfileProviderAttribute)
                                    {
                                        prov = ProfileManager.Providers[((ProfileProviderAttribute)attrib).ProviderName];
                                        if (prov == null)
                                        {
                                            throw new ConfigurationErrorsException(SR.GetString(SR.Profile_provider_not_found, ((ProfileProviderAttribute)attrib).ProviderName), config.ElementInformation.Properties["inherits"].Source, config.ElementInformation.Properties["inherits"].LineNumber);
                                        }
                                    }
                                }
                                //////////////////////////////////////////////////////////////////////
                                // Step 5: Add the property to the s_Properties
                                SettingsAttributeDictionary settings = new SettingsAttributeDictionary();
                                settings.Add("AllowAnonymous", allowAnonymous);
                                if (!string.IsNullOrEmpty(customData))
                                {
                                    settings.Add("CustomProviderData", customData);
                                }
                                SettingsProperty sp = new SettingsProperty(prop.Name, prop.PropertyType, prov, readOnly, defaultValue, serializeAs, settings, false, true);
                                s_Properties.Add(sp);
                            }
                        }
                    }

                    //////////////////////////////////////////////////////////////////////
                    //////////////////////////////////////////////////////////////////////
                    // Step 6: Add all properties from config
                    if (config.PropertySettings != null)
                    {
                        AddPropertySettingsFromConfig(baseType, fAnonEnabled, hasLowTrust, config.PropertySettings, null);
                        foreach (ProfileGroupSettings pgs in config.PropertySettings.GroupSettings)
                        {
                            AddPropertySettingsFromConfig(baseType, fAnonEnabled, hasLowTrust, pgs.PropertySettings, pgs.Name);
                        }
                    }
                }
                catch (Exception e) {
                    if (s_InitializeException == null)
                    {
                        s_InitializeException = e;
                    }
                }
                // If there are no properties, create an empty collection.
                if (s_Properties == null)
                {
                    s_Properties = new SettingsPropertyCollection();
                }
                // Make the properties collection read-only
                s_Properties.SetReadOnly();
                s_Initialized = true;
            }

            // Throw an exception if there was an exception during initialization
            if (s_InitializeException != null)
            {
                throw s_InitializeException;
            }
        }
예제 #14
0
 private static void InitializeStatic()
 {
     if (!ProfileManager.Enabled || s_Initialized)
     {
         if (s_InitializeException != null)
         {
             throw s_InitializeException;
         }
     }
     else
     {
         lock (s_InitializeLock)
         {
             if (s_Initialized)
             {
                 if (s_InitializeException != null)
                 {
                     throw s_InitializeException;
                 }
                 return;
             }
             try
             {
                 ProfileSection profileAppConfig = MTConfigUtil.GetProfileAppConfig();
                 bool           fAnonEnabled     = HostingEnvironment.IsHosted ? AnonymousIdentificationModule.Enabled : true;
                 Type           inheritsFromType = InheritsFromType;
                 bool           hasLowTrust      = HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Low);
                 s_Properties = new SettingsPropertyCollection();
                 AddPropertySettingsFromConfig(inheritsFromType, fAnonEnabled, hasLowTrust, ProfileManager.DynamicProfileProperties, null);
                 if (inheritsFromType != typeof(ProfileBase))
                 {
                     PropertyInfo[]      properties = typeof(ProfileBase).GetProperties();
                     NameValueCollection values     = new NameValueCollection(properties.Length);
                     foreach (PropertyInfo info in properties)
                     {
                         values.Add(info.Name, string.Empty);
                     }
                     foreach (PropertyInfo info2 in inheritsFromType.GetProperties())
                     {
                         if (values[info2.Name] == null)
                         {
                             ProfileProvider     provider           = hasLowTrust ? ProfileManager.Provider : null;
                             bool                isReadOnly         = false;
                             SettingsSerializeAs providerSpecific   = SettingsSerializeAs.ProviderSpecific;
                             string              defaultValue       = string.Empty;
                             bool                allow              = false;
                             string              customProviderData = null;
                             foreach (Attribute attribute in Attribute.GetCustomAttributes(info2, true))
                             {
                                 if (attribute is SettingsSerializeAsAttribute)
                                 {
                                     providerSpecific = ((SettingsSerializeAsAttribute)attribute).SerializeAs;
                                 }
                                 else if (attribute is SettingsAllowAnonymousAttribute)
                                 {
                                     allow = ((SettingsAllowAnonymousAttribute)attribute).Allow;
                                     if (!fAnonEnabled && allow)
                                     {
                                         throw new ConfigurationErrorsException(System.Web.SR.GetString("Annoymous_id_module_not_enabled", new object[] { info2.Name }), profileAppConfig.ElementInformation.Properties["inherits"].Source, profileAppConfig.ElementInformation.Properties["inherits"].LineNumber);
                                     }
                                 }
                                 else if (attribute is ReadOnlyAttribute)
                                 {
                                     isReadOnly = ((ReadOnlyAttribute)attribute).IsReadOnly;
                                 }
                                 else if (attribute is DefaultSettingValueAttribute)
                                 {
                                     defaultValue = ((DefaultSettingValueAttribute)attribute).Value;
                                 }
                                 else if (attribute is CustomProviderDataAttribute)
                                 {
                                     customProviderData = ((CustomProviderDataAttribute)attribute).CustomProviderData;
                                 }
                                 else if (hasLowTrust && (attribute is ProfileProviderAttribute))
                                 {
                                     provider = ProfileManager.Providers[((ProfileProviderAttribute)attribute).ProviderName];
                                     if (provider == null)
                                     {
                                         throw new ConfigurationErrorsException(System.Web.SR.GetString("Profile_provider_not_found", new object[] { ((ProfileProviderAttribute)attribute).ProviderName }), profileAppConfig.ElementInformation.Properties["inherits"].Source, profileAppConfig.ElementInformation.Properties["inherits"].LineNumber);
                                     }
                                 }
                             }
                             SettingsAttributeDictionary attributes = new SettingsAttributeDictionary();
                             attributes.Add("AllowAnonymous", allow);
                             if (!string.IsNullOrEmpty(customProviderData))
                             {
                                 attributes.Add("CustomProviderData", customProviderData);
                             }
                             SettingsProperty property = new SettingsProperty(info2.Name, info2.PropertyType, provider, isReadOnly, defaultValue, providerSpecific, attributes, false, true);
                             s_Properties.Add(property);
                         }
                     }
                 }
                 if (profileAppConfig.PropertySettings != null)
                 {
                     AddPropertySettingsFromConfig(inheritsFromType, fAnonEnabled, hasLowTrust, profileAppConfig.PropertySettings, null);
                     foreach (ProfileGroupSettings settings in profileAppConfig.PropertySettings.GroupSettings)
                     {
                         AddPropertySettingsFromConfig(inheritsFromType, fAnonEnabled, hasLowTrust, settings.PropertySettings, settings.Name);
                     }
                 }
             }
             catch (Exception exception)
             {
                 if (s_InitializeException == null)
                 {
                     s_InitializeException = exception;
                 }
             }
             if (s_Properties == null)
             {
                 s_Properties = new SettingsPropertyCollection();
             }
             s_Properties.SetReadOnly();
             s_Initialized = true;
         }
         if (s_InitializeException != null)
         {
             throw s_InitializeException;
         }
     }
 }