• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Configuration.SettingsPropertyValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例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: CreatePropNode

        private void CreatePropNode(SettingsProperty setting, SettingsPropertyValue value, SettingsContext context)
        {
            string xPathQuery = getXPathQuerySection(setting, context);

            XmlNode groupNode = doc.SelectSingleNode(xPathQuery);

            if (groupNode == null)
            {
                groupNode = doc.CreateElement(GetSectionName(context));

                if (this.IsUserScoped(setting))
                {
                    userSettings.AppendChild(groupNode);
                }
                else
                {
                    appSettings.AppendChild(groupNode);
                }

            } //if (node == null)

            XmlNode nodeProp = doc.CreateElement(setting.Name);

            nodeProp.AppendChild(this.SerializeToXmlElement(setting, value));

            groupNode.AppendChild(nodeProp);
        }
开发者ID:nrother,项目名称:fast-view,代码行数:27,代码来源:SettingsProvider.cs


示例4: 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


示例5: 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


示例6: 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


示例7: 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


示例8: 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


示例9: SettingValuesCreatesAnAppAndUserId

    public void SettingValuesCreatesAnAppAndUserId()
    {
      MySQLProfileProvider provider = InitProfileProvider();
      SettingsContext ctx = new SettingsContext();
      ctx.Add("IsAuthenticated", false);
      ctx.Add("UserName", "user1");

      SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();
      SettingsProperty property1 = new SettingsProperty("color");
      property1.PropertyType = typeof(string);
      property1.Attributes["AllowAnonymous"] = true;
      SettingsPropertyValue value = new SettingsPropertyValue(property1);
      value.PropertyValue = "blue";
      values.Add(value);

      provider.SetPropertyValues(ctx, values);

      DataTable dt = FillTable("SELECT * FROM my_aspnet_applications");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_users");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_profiles");
      Assert.AreEqual(1, dt.Rows.Count);

      values["color"].PropertyValue = "green";
      provider.SetPropertyValues(ctx, values);

      dt = FillTable("SELECT * FROM my_aspnet_applications");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_users");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_profiles");
      Assert.AreEqual(1, dt.Rows.Count);
    }
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:34,代码来源:ProfileTests.cs


示例10: Add

		public void Add (SettingsPropertyValue property)
		{
			if (isReadOnly)
				throw new NotSupportedException ();

			/* actually do the add */
			items.Add (property.Name, property);
		}
开发者ID:Xipas,项目名称:Symplified.Auth,代码行数:8,代码来源:SettingsPropertyValueCollection.cs


示例11: 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


示例12: SalesforceProfilePropertyValue

 public SalesforceProfilePropertyValue(SettingsPropertyValue propertyValue, SalesforceProfileProperty property)
     : base(property)
 {
     base.PropertyValue = propertyValue.PropertyValue;
       base.Deserialized = propertyValue.Deserialized;
       base.IsDirty = propertyValue.IsDirty;
       base.SerializedValue = propertyValue.SerializedValue;
 }
开发者ID:clone278,项目名称:sitecore-salesforce-connect,代码行数:8,代码来源:SalesforceProfilePropertyValue.cs


示例13: GetPropertyValues

		public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection props) {
			var values = new SettingsPropertyValueCollection();
			foreach (SettingsProperty property in props) {
				var value2 = new SettingsPropertyValue(property) {
					IsDirty = false,
					SerializedValue = GetValue(property)
				};
				values.Add(value2);
			}
			return values;
		}
开发者ID:CyberFoxHax,项目名称:PCSXBonus,代码行数:11,代码来源:PortableSettingsProvider.cs


示例14: MigrateProperty

		private static void MigrateProperty(IMigrateSettings customMigrator, MigrationScope migrationScope, 
		                                    SettingsPropertyValue currentValue, object previousValue)
		{
			var migrationValues = new SettingsPropertyMigrationValues(
				currentValue.Property.Name, migrationScope, 
				currentValue.PropertyValue, previousValue);

			customMigrator.MigrateSettingsProperty(migrationValues);
			if (!Equals(migrationValues.CurrentValue, currentValue.PropertyValue))
				currentValue.PropertyValue = migrationValues.CurrentValue;
		}
开发者ID:khaha2210,项目名称:radio,代码行数:11,代码来源:ApplicationSettingsExtensions.cs


示例15: SetPropertyValues

		public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
		{
			foreach (SettingsPropertyValue value in collection)
			{
				SettingsPropertyValue existing = SimpleSettingsStore.Instance.CurrentUserValues[value.Name];
				if (existing == null)
					SimpleSettingsStore.Instance.CurrentUserValues.Add(existing = new SettingsPropertyValue(value.Property));

				existing.PropertyValue = value.PropertyValue;
			}
		}
开发者ID:khaha2210,项目名称:radio,代码行数:11,代码来源:TestSettingsProvider.cs


示例16: ApplySettingToValue

        /// <summary>
        /// Checks the specified settings collection to see if it has a serialized value that should
        /// be applied to the specified <see cref="SettingsPropertyValue"/>.
        /// </summary>
        /// <param name="value">An individual settings property value.</param>
        /// <param name="settings">A collection representing the settings.</param>
        private static void ApplySettingToValue(SettingsPropertyValue value, SettingElementCollection settings)
        {
            var setting = settings.Get(value.Name);
            if (setting != null)
            {
                value.SerializedValue = setting.Value.ValueXml.InnerText;

                // Mark the value as not deserialized, which will trigger a deserialization of the SerializedValue into the PropertyValue.
                value.Deserialized = false;
            }
        }
开发者ID:reima,项目名称:codemaid,代码行数:17,代码来源:CodeMaidSettingsProvider.cs


示例17: Add

		public void Add ()
		{
			SettingsPropertyValueCollection col = new SettingsPropertyValueCollection ();
			SettingsProperty test_prop = new SettingsProperty ("test_prop");
			SettingsPropertyValue val = new SettingsPropertyValue (test_prop);

			Assert.AreEqual (0, col.Count, "A1");

			col.Add (val);

			Assert.AreEqual (1, col.Count, "A2");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:SettingsPropertyValueCollectionTest.cs


示例18: GetPropertyValues

        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
        {
            SettingsPropertyValueCollection spCollection = new SettingsPropertyValueCollection();
            foreach (SettingsProperty settingsProperty in collection)
            {
                SettingsPropertyValue spVal = new SettingsPropertyValue(settingsProperty);
                spVal.PropertyValue = String.Empty;
                spCollection.Add(spVal);
            }

            return spCollection;
        }
开发者ID:shanegarven,项目名称:E80.General,代码行数:12,代码来源:CustomSettingsProvider.cs


示例19: GetPropertyValues

        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection props)
        {
            // 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;
                value.SerializedValue = (string)GetRegKey(setting).GetValue(setting.Name);
                values.Add(value);
            }
            return values;
        }
开发者ID:ianchi,项目名称:CiscoDialerAddIn,代码行数:15,代码来源:RegistrySettingsProvider.cs


示例20: GetPropertyValues

        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
        {
            Configuration config = null;
            ClientSettingsSection clientSettings = null;

            // 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 app-level settings
            config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ConfigurationSectionGroup configSectionGroup = config.GetSectionGroup(APP_SETTINGS_SECTION_GROUP_NAME);
            if (configSectionGroup != null)
            {
                ConfigurationSection configSection = configSectionGroup.Sections[APP_SETTINGS_SECTION_NAME];
                if (configSection != null)
                {
                    clientSettings = (ClientSettingsSection)configSection;
                    foreach (SettingsPropertyValue spv in settings)
                    {
                        DeserializeFromXmlElement(spv.Property, spv, clientSettings);
                    }
                }
            }

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

            return settings;
        }
开发者ID:iwaim,项目名称:growl-for-windows,代码行数:47,代码来源:UserSettingsProvider.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap