当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.SettingsPropertyCollection类代码示例

本文整理汇总了C#中System.Configuration.SettingsPropertyCollection的典型用法代码示例。如果您正苦于以下问题:C# SettingsPropertyCollection类的具体用法?C# SettingsPropertyCollection怎么用?C# SettingsPropertyCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SettingsPropertyCollection类属于System.Configuration命名空间,在下文中一共展示了SettingsPropertyCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Clone

		public object Clone ()
		{
			SettingsPropertyCollection col = new SettingsPropertyCollection ();
			col.items = (Hashtable)items.Clone ();

			return col;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:SettingsPropertyCollection.cs

示例2: GetPropertyValues

		public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection props)
		{
			XmlSettingsFile localFile = XmlSettingsFile.GetLocalSettingsFile(GetTypeFromContext(context));
			XmlSettingsFile roamingFile = XmlSettingsFile.GetRoamingSettingsFile(GetTypeFromContext(context));
			SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();

			foreach (SettingsProperty setting in props)
			{
				SettingsPropertyValue value = new SettingsPropertyValue(setting);
				value.IsDirty = false;

				if (IsRoaming(setting))
				{
					value.SerializedValue = roamingFile.GetValue(setting);
				}
				else
				{
					value.SerializedValue = localFile.GetValue(setting);
				}

				values.Add(value);
			}

			return values;
		}
开发者ID:fparisotto,项目名称:ClearCanvas-Contrib,代码行数:25,代码来源:DllSettingsProvider.cs

示例3: GetPropertyValues

        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context,
            SettingsPropertyCollection collection)
        {
            var properties = new SettingsPropertyValueCollection();
            if (collection.Count < 1)
                return properties;

            var username = (string) context["UserName"];
            foreach (SettingsProperty property in collection)
            {
                properties.Add(new SettingsPropertyValue(property));
            }

            var db = new MyLifeEntities();
            var profile = db.tblProfiles.Where(item => item.UserName == username).FirstOrDefault();
            if (profile != null)
            {
                var names =
                    profile.PropertyNames.Split(new[] {";#"}, StringSplitOptions.RemoveEmptyEntries);
                var values =
                    profile.PropertyValues.Split(new[] {";#"}, StringSplitOptions.RemoveEmptyEntries);
                if (names.Length > 0 && values.Length > 0)
                {
                    for (var i = 0; i < names.Length; i++)
                    {
                        var property = properties[names[i]];
                        if (property == null) continue;
                        property.PropertyValue = Base64Serializer.Deserialize(values[i]);
                    }
                }
            }

            return properties;
        }
开发者ID:preguntoncojonero,项目名称:mylifevn,代码行数:34,代码来源:SqlServerProfileProvider.cs

示例4: GetPropertyValues

        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context,
            SettingsPropertyCollection collection)
        {
            SettingsPropertyValueCollection result = new SettingsPropertyValueCollection();
            if (collection.Count < 1)
                return result;

            string userEmail = (string) context["UserName"]; //Эта строка мне пока не понятна
            if (string.IsNullOrEmpty(userEmail))
                return result;

            var user = UserService.GetByEmail(userEmail);
            var profile = ProfileService.GetProfile(user);

            foreach (SettingsProperty prop in collection)
            {
                SettingsPropertyValue svp = new SettingsPropertyValue(prop)
                {
                    PropertyValue = profile.GetType().GetProperty(prop.Name).GetValue(profile, null)
                };

                result.Add(svp);
            }

            return result;
        }
开发者ID:MashukW,项目名称:BSU.ASP1501.FinalProject.Mashuk,代码行数:26,代码来源:SNProfileProvider.cs

示例5: GetPropertyValues

        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the property values from a config file.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context,
			SettingsPropertyCollection properties)
        {
            // Set the config files
            var configMap = SetConfigFiles();

            // Create new collection of values
            var values = new SettingsPropertyValueCollection();

            ReadProperties(context, properties, configMap, ConfigurationUserLevel.None,
                values);
            ReadProperties(context, properties, configMap,
                ConfigurationUserLevel.PerUserRoamingAndLocal, values);
            ReadProperties(context, properties, configMap, ConfigurationUserLevel.PerUserRoaming,
                values);

            // save new user config file
            try
            {
                SetPropertyValues(context, values);
            }
            catch
            {
            }

            return values;
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:32,代码来源:LibSettingsProvider.cs

示例6: GetPropertyValues

        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
        {
            // set all of the inherited default values first in case we have failure later
            SettingsPropertyValueCollection settings = new SettingsPropertyValueCollection();
            foreach (SettingsProperty prop in collection)
            {
                SettingsPropertyValue spv = new SettingsPropertyValue(prop);
                spv.SerializedValue = prop.DefaultValue;
                settings.Add(spv);
            }

            // now read in overridden user settings
            try
            {
                Configuration config = null;
                ClientSettingsSection clientSettings = GetUserSettings(out config, true);
                foreach (SettingsPropertyValue spv in settings)
                {
                    DeserializeFromXmlElement(spv.Property, spv, clientSettings);
                }
            }
            catch
            {
                // suppress
            }

            return settings;
        }
开发者ID:Tadwork,项目名称:Growl-For-Windows,代码行数:28,代码来源:UserSettingsProvider.cs

示例7: LoadValues

        public SettingsPropertyValueCollection LoadValues(string userName, SettingsPropertyCollection props)
        {
            var svc = new SettingsPropertyValueCollection();
            // holds sourcename->data pairs
            var loadedData = new Dictionary<string, IDictionary>();
            foreach (SettingsProperty prop in props) {
                EnsureDataLoaded(userName, prop.Name, loadedData);
                var pv = new SettingsPropertyValue(prop);

                object value = null;
                // lets try to locate property value
                foreach (var src in Sources)
                    if (src.FieldsMapping.ContainsKey(prop.Name)) {
                        value = loadedData[src.SourceName][ ResolveFieldName(prop.Name,src) ];
                        break;
                    }
                if (value == null || value == DBNull.Value) {
                    // leave default value
                } else {
                    pv.PropertyValue = value;
                    pv.IsDirty = false;
                }

                svc.Add(pv);
            }
            return svc;
        }
开发者ID:Mariamfelicia,项目名称:nreco,代码行数:27,代码来源:DalcProfileStorage.cs

示例8: GetPropertyValues

		/// <summary>
		/// Returns the collection of settings property values for the specified application instance and settings property group.
		/// </summary>
		/// <param name="context">A System.Configuration.SettingsContext describing the current application use.</param>
		/// <param name="collection">A System.Configuration.SettingsPropertyCollection containing the settings property group whose values are to be retrieved.</param>
		/// <returns>A System.Configuration.SettingsPropertyValueCollection containing the values for the specified settings property group.</returns>
		public override SettingsPropertyValueCollection GetPropertyValues(
			SettingsContext context, SettingsPropertyCollection collection)
		{
			string username        = (string)context["UserName"];
			bool   isAuthenticated = (bool)  context["IsAuthenticated"];

			SettingsPropertyValueCollection svc = new SettingsPropertyValueCollection();

			foreach (SettingsProperty prop in collection)
			{
				SettingsPropertyValue pv = new SettingsPropertyValue(prop);

				switch (pv.Property.Name)
				{
					case PROFILE_SHOPPINGCART: pv.PropertyValue = GetCartItems(username, true);  break;
					case PROFILE_WISHLIST:     pv.PropertyValue = GetCartItems(username, false); break;
					case PROFILE_ACCOUNT:
						if (isAuthenticated)
							pv.PropertyValue = GetAccountInfo(username);
						break;

					default:
						throw new ApplicationException(ERR_INVALID_PARAMETER + " name.");
				}

				svc.Add(pv);
			}

			return svc;
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:36,代码来源:ProfileProvider.cs

示例9: GetPropertyValues

        private SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties, bool returnPrevious)
		{
			Type settingsClass = (Type)context["SettingsClassType"];
			string settingsKey = (string)context["SettingsKey"];
			string user = Thread.CurrentPrincipal.Identity.Name;

			var group = new SettingsGroupDescriptor(settingsClass);
			if (returnPrevious)
			    group = _store.GetPreviousSettingsGroup(group);
			else if (AnyUserScoped(properties))
				SettingsMigrator.MigrateUserSettings(group);

			var storedValues = new Dictionary<string, string>();

			if (group != null)
			{
				foreach (var userDefault in _store.GetSettingsValues(group, null, settingsKey))
					storedValues[userDefault.Key] = userDefault.Value;

				foreach (var userValue in _store.GetSettingsValues(group, user, settingsKey))
					storedValues[userValue.Key] = userValue.Value;
			}

		    return GetSettingsValues(properties, storedValues);
		}
开发者ID:khaha2210,项目名称:radio,代码行数:25,代码来源:SettingsStoreSettingsProvider.cs

示例10: GetSharedPropertyValues

        public static SettingsPropertyValueCollection GetSharedPropertyValues(LocalFileSettingsProvider provider, SettingsContext context, SettingsPropertyCollection properties, string currentExeConfigFilename = null)
        {
			var settingsClass = (Type)context["SettingsClassType"];

            var systemConfiguration = String.IsNullOrEmpty(currentExeConfigFilename)
                              ? SystemConfigurationHelper.GetExeConfiguration()
                              : SystemConfigurationHelper.GetExeConfiguration(currentExeConfigFilename);

        	var storedValues = systemConfiguration.GetSettingsValues(settingsClass);

			// Create new collection of values
			var values = new SettingsPropertyValueCollection();

			foreach (SettingsProperty setting in properties)
			{
				var value = new SettingsPropertyValue(setting)
				{
					SerializedValue = storedValues.ContainsKey(setting.Name) ? storedValues[setting.Name] : null,
					IsDirty = false
				};

				// use the stored value, or set the SerializedValue to null, which tells .NET to use the default value
				values.Add(value);
			}

			return values;
		}
开发者ID:nhannd,项目名称:Xian,代码行数:27,代码来源:LocalFileSettingsProviderExtensions.cs

示例11: GetPropertyValues

    	///<summary>
    	///Returns the collection of settings property values for the specified application instance and settings property group.
    	///</summary>
    	public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection props)
        {
            Type settingsClass = (Type)context["SettingsClassType"];
            string settingsKey = (string)context["SettingsKey"];
            string user = Thread.CurrentPrincipal.Identity.Name;

            // load settings from store
            Dictionary<string, string> storedValues = _store.GetSettingsValues(
                new SettingsGroupDescriptor(settingsClass), user, settingsKey);

            // Create new collection of values
            SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();

            // Iterate through the settings to be retrieved
            foreach (SettingsProperty setting in props)
            {
                SettingsPropertyValue value = new SettingsPropertyValue(setting);
                value.IsDirty = false;

                // use the stored value, or set the SerializedValue to null, which tells .NET to use the default value
                value.SerializedValue = storedValues.ContainsKey(setting.Name) ? storedValues[setting.Name] : null;
                values.Add(value);
            }
 
            return values;
        }
开发者ID:scottshea,项目名称:monodicom,代码行数:29,代码来源:SettingsStoreSettingsProvider.cs

示例12: GetPropertyValues

        /// <summary>
        /// Must override this, this is the bit that matches up the designer properties to the dictionary values
        /// </summary>
        /// <param name="context"></param>
        /// <param name="collection"></param>
        /// <returns></returns>
        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
        {
            //load the file
            if (!_loaded)
            {
                _loaded = true;
                LoadValuesFromFile();
            }

            //collection that will be returned.
            SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();

            //itterate thought the properties we get from the designer, checking to see if the setting is in the dictionary
            foreach (SettingsProperty setting in collection)
            {
                SettingsPropertyValue value = new SettingsPropertyValue(setting);
                value.IsDirty = false;

                if (SettingsDictionary.ContainsKey(setting.Name))
                {
                    value.SerializedValue = SettingsDictionary[setting.Name].value;
                }
                else //use defaults in the case where there are no settings yet
                {
                    value.SerializedValue = setting.DefaultValue == null ? string.Empty : setting.DefaultValue.ToString();
                }

                values.Add(value);
            }
            return values;
        }
开发者ID:mihailim,项目名称:PoESkillTree,代码行数:37,代码来源:CustomSettingsProvider.cs

示例13: GetPropertyValues

        /// <summary>
        /// Returns the collection of settings property values for the specified application instance and settings property group.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Configuration.SettingsPropertyValueCollection"/> containing the values for the specified settings property group.
        /// </returns>
        /// <param name="context">A <see cref="T:System.Configuration.SettingsContext"/> describing the current application use.
        ///                 </param><param name="collection">A <see cref="T:System.Configuration.SettingsPropertyCollection"/> containing the settings property group whose values are to be retrieved.
        ///                 </param><filterpriority>2</filterpriority>
        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
        {
            var username = (string) context["UserName"];
            var isAuthenticated = (bool) context["IsAuthenticated"];
            Profile profile = ProfileManager.Instance.GetCurrentUser(username);

            var svc = new SettingsPropertyValueCollection();

            foreach (SettingsProperty prop in collection)
            {
                var pv = new SettingsPropertyValue(prop);

                switch (pv.Property.Name)
                {
                    case _PROFILE_SHOPPINGCART:
                        pv.PropertyValue = CartList.GetCart(profile.UniqueID, true);
                        break;
                    case _PROFILE_WISHLIST:
                        pv.PropertyValue = CartList.GetCart(profile.UniqueID, false);
                        break;
                    case _PROFILE_ACCOUNT:
                        if (isAuthenticated)
                            pv.PropertyValue = new Address(profile);
                        break;
                    default:
                        throw new ApplicationException(string.Format("{0} name.", _ERR_INVALID_PARAMETER));
                }

                svc.Add(pv);
            }
            return svc;
        }
开发者ID:codesmithtools,项目名称:Framework-Samples,代码行数:41,代码来源:PetShopProfileProvider.cs

示例14: GetPropertyValues

		/// <summary>
		/// Must override this, this is the bit that matches up the designer properties to the dictionary values
		/// </summary>
		/// <param name="context"></param>
		/// <param name="collection"></param>
		/// <returns></returns>
		public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection) {
			//load the file
			if (!_loaded) {
				_loaded = true;
				LoadValuesFromFile();
			}

			//collection that will be returned.
			SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();

			//itterate thought the properties we get from the designer, checking to see if the setting is in the dictionary
			foreach (SettingsProperty setting in collection) {
				SettingsPropertyValue value = new SettingsPropertyValue(setting);
				value.IsDirty = false;

				//need the type of the value for the strong typing
				var t = Type.GetType(setting.PropertyType.FullName);

				if (SettingsDictionary.ContainsKey(setting.Name)) {
					value.SerializedValue = SettingsDictionary[setting.Name].value;
					value.PropertyValue = Convert.ChangeType(SettingsDictionary[setting.Name].value, t);
				}
				else //use defaults in the case where there are no settings yet
				{
					value.SerializedValue = setting.DefaultValue;
					value.PropertyValue = Convert.ChangeType(setting.DefaultValue, t);
				}

				values.Add(value);
			}
			return values;
		}
开发者ID:dkeetonx,项目名称:ccmaps-net,代码行数:38,代码来源:CustomSettingsProvider.cs

示例15: GetPropertyValues

 public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
 {
     SettingsPropertyValueCollection v = new SettingsPropertyValueCollection();
     value = new SettingsPropertyValue(new SettingsProperty("Style"));
     value.PropertyValue = "null";
     v.Add(value);
     return v;
 }
开发者ID:JefferyXuHao,项目名称:Contra-DC,代码行数:8,代码来源:ContraSettingsProvider.cs


注:本文中的System.Configuration.SettingsPropertyCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。