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

C# Configuration.SettingsProperty类代码示例

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

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



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

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


示例2: GetDescription

		public static string GetDescription(SettingsProperty property)
		{
			SettingsDescriptionAttribute a = CollectionUtils.SelectFirst(property.Attributes,
						attribute => attribute is SettingsDescriptionAttribute) as SettingsDescriptionAttribute;

			return a == null ? "" : a.Description;
		}
开发者ID:khaha2210,项目名称:radio,代码行数:7,代码来源:SettingsPropertyExtensions.cs


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


示例4: Settings

        public Settings()
        {
            // // To add event handlers for saving and changing settings, uncomment the lines below:
            //
            // this.SettingChanging += this.SettingChangingEventHandler;
            //
            // this.SettingsSaving += this.SettingsSavingEventHandler;
            //

            for (int i = 0; i < MaxExternalTools; i++)
            {
                SettingsProperty newProp = new SettingsProperty(
                    "ExternalTool" + i, typeof(ExternalTool),
                    this.Providers[Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location)],
                    false,
                    null,
                    SettingsSerializeAs.String,
                    null,
                    true, true
                );
                this.Properties.Add(newProp);
            }

            this.SettingsLoaded += new System.Configuration.SettingsLoadedEventHandler(Settings_SettingsLoaded);
        }
开发者ID:hejob,项目名称:SB3Utility,代码行数:25,代码来源:Settings.cs


示例5: CreateSetting

 private SettingsProperty CreateSetting(PropertyInfo propInfo)
 {
     object[] customAttributes = propInfo.GetCustomAttributes(false);
     SettingsProperty property = new SettingsProperty(this.Initializer);
     bool flag = this._explicitSerializeOnClass;
     property.Name = propInfo.Name;
     property.PropertyType = propInfo.PropertyType;
     for (int i = 0; i < customAttributes.Length; i++)
     {
         Attribute attribute = customAttributes[i] as Attribute;
         if (attribute != null)
         {
             if (attribute is DefaultSettingValueAttribute)
             {
                 property.DefaultValue = ((DefaultSettingValueAttribute) attribute).Value;
             }
             else if (attribute is ReadOnlyAttribute)
             {
                 property.IsReadOnly = true;
             }
             else if (attribute is SettingsProviderAttribute)
             {
                 string providerTypeName = ((SettingsProviderAttribute) attribute).ProviderTypeName;
                 Type type = Type.GetType(providerTypeName);
                 if (type == null)
                 {
                     throw new ConfigurationErrorsException(System.SR.GetString("ProviderTypeLoadFailed", new object[] { providerTypeName }));
                 }
                 SettingsProvider provider = SecurityUtils.SecureCreateInstance(type) as SettingsProvider;
                 if (provider == null)
                 {
                     throw new ConfigurationErrorsException(System.SR.GetString("ProviderInstantiationFailed", new object[] { providerTypeName }));
                 }
                 provider.Initialize(null, null);
                 provider.ApplicationName = ConfigurationManagerInternalFactory.Instance.ExeProductName;
                 SettingsProvider provider2 = this._providers[provider.Name];
                 if (provider2 != null)
                 {
                     provider = provider2;
                 }
                 property.Provider = provider;
             }
             else if (attribute is SettingsSerializeAsAttribute)
             {
                 property.SerializeAs = ((SettingsSerializeAsAttribute) attribute).SerializeAs;
                 flag = true;
             }
             else
             {
                 property.Attributes.Add(attribute.GetType(), attribute);
             }
         }
     }
     if (!flag)
     {
         property.SerializeAs = this.GetSerializeAs(propInfo.PropertyType);
     }
     return property;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:59,代码来源:ApplicationSettingsBase.cs


示例6: ProfilePropertyViewModel

 public ProfilePropertyViewModel(SettingsProperty property, ProfilePropertyInputModel value)
 {
     Type = PropTypeFromPropertyType(property);
     Description = property.Name + " must be of type " + property.PropertyType.Name;
     if (property.PropertyType.IsValueType) Description += " and is required";
     Description += ".";
     Data = value;
 }
开发者ID:Wolfium,项目名称:Thinktecture.IdentityServer.v2,代码行数:8,代码来源:UserProfileViewModel.cs


示例7: ProfilePropertyViewModel

 public ProfilePropertyViewModel(SettingsProperty property, string value)
     : this(property, 
             new ProfilePropertyInputModel
             {
                 Name = property.Name,
                 Value = value
             })
 {
 }
开发者ID:FCSAmerica,项目名称:SecureTokenServer,代码行数:9,代码来源:UserProfileViewModel.cs


示例8: CreateProperty

            private Property CreateProperty(PropertyInfo property, SettingsProperty settingsProperty, SettingsPropertyValueCollection settingsPropertyValues)
            {
                var descriptor = new SettingsPropertyDescriptor(property);
                var settingsPropertyValue = settingsPropertyValues[settingsProperty.Name];
                var defaultValue = settingsProperty.DefaultValue;
                var serializedValue = settingsPropertyValue == null ? null : settingsPropertyValue.SerializedValue;

                return new Property(descriptor, (serializedValue ?? defaultValue).ToString());
            }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:9,代码来源:SettingsManagementComponent2.cs


示例9: Add

		public void Add ()
		{
			SettingsPropertyCollection col = new SettingsPropertyCollection ();
			SettingsProperty test_prop = new SettingsProperty ("test_prop");

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

			col.Add (test_prop);

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


示例10: SettingsProperty

		public SettingsProperty (SettingsProperty propertyToCopy)
			: this (propertyToCopy.Name,
				propertyToCopy.PropertyType,
				propertyToCopy.Provider,
				propertyToCopy.IsReadOnly,
				propertyToCopy.DefaultValue,
				propertyToCopy.SerializeAs,
				new SettingsAttributeDictionary (propertyToCopy.Attributes),
				propertyToCopy.ThrowOnErrorDeserializing,
				propertyToCopy.ThrowOnErrorSerializing)
		{
		}
开发者ID:Xipas,项目名称:Symplified.Auth,代码行数:12,代码来源:SettingsProperty.cs


示例11: IsRoaming

 private bool IsRoaming(SettingsProperty prop)
 {
     foreach (DictionaryEntry entry in prop.Attributes)
     {
         Attribute attribute = (Attribute) entry.Value;
         if (attribute is SettingsManageabilityAttribute)
         {
             return true;
         }
     }
     return false;
 }
开发者ID:CyberFoxHax,项目名称:PCSXBonus,代码行数:12,代码来源:PortableSettingsProvider.cs


示例12: SettingsProperty

 ////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////
 public SettingsProperty(SettingsProperty propertyToCopy) 
 {
     _Name = propertyToCopy.Name;
     _IsReadOnly = propertyToCopy.IsReadOnly;
     _DefaultValue = propertyToCopy.DefaultValue;
     _SerializeAs = propertyToCopy.SerializeAs;
     _Provider = propertyToCopy.Provider;
     _PropertyType = propertyToCopy.PropertyType;
     _ThrowOnErrorDeserializing = propertyToCopy.ThrowOnErrorDeserializing;
     _ThrowOnErrorSerializing = propertyToCopy.ThrowOnErrorSerializing;
     _Attributes = new SettingsAttributeDictionary(propertyToCopy.Attributes);
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:14,代码来源:SettingsProperty.cs


示例13: Add

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

			OnAdd (property);

			/* actually do the add */
			items.Add (property.Name, property);

			OnAddComplete (property);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:12,代码来源:SettingsPropertyCollection.cs


示例14: GetSettingConverter

		static SettingsPropertyValue GetSettingConverter(Type type, string name)
		{
			TypeConverter c = TypeDescriptor.GetConverter(type);
			SettingsSerializeAs ssa;
			if (c.CanConvertFrom(typeof(string)) && c.CanConvertTo(typeof(string))) {
				ssa = SettingsSerializeAs.String;
			} else {
				ssa = SettingsSerializeAs.Xml;
			}
			SettingsProperty p = new SettingsProperty(name);
			p.PropertyType = type;
			p.SerializeAs = ssa;
			return new SettingsPropertyValue(p);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:14,代码来源:SettingsEntry.cs


示例15: Remove

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

			col.Add (val);

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

			col.Remove ("test_prop");

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


示例16: Add

       ////////////////////////////////////////////////////////////
       ////////////////////////////////////////////////////////////
       public void Add(SettingsProperty property)
       {
           if (_ReadOnly)
               throw new NotSupportedException();

           OnAdd(property);
           _Hashtable.Add(property.Name, property);
           try {
               OnAddComplete(property);
           }
           catch {
               _Hashtable.Remove(property.Name);
               throw;
           }
       }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:17,代码来源:settingspropertycollection.cs


示例17: GetValue

 private string GetValue(SettingsProperty setting)
 {
     try
     {
         return this.SettingsXML.SelectSingleNode("Settings/" + setting.Name).InnerText;
     }
     catch (Exception)
     {
         if (setting.DefaultValue != null)
         {
             return setting.DefaultValue.ToString();
         }
         return "";
     }
 }
开发者ID:CyberFoxHax,项目名称:PCSXBonus,代码行数:15,代码来源:PortableSettingsProvider.cs


示例18: Ctor_1

		public void Ctor_1 ()
		{
			SettingsProperty p = new SettingsProperty ("property",
								   typeof (int),
								   null,
								   true,
								   10,
								   SettingsSerializeAs.Binary,
								   null,
								   true,
								   false);

			Assert.AreEqual ("property", p.Name, "A1");
			Assert.AreEqual (typeof (int), p.PropertyType, "A2");
			Assert.AreEqual (null, p.Provider, "A3");
			Assert.AreEqual (10, (int)p.DefaultValue, "A4");
			Assert.AreEqual (SettingsSerializeAs.Binary, p.SerializeAs, "A5");
			Assert.IsNull (p.Attributes, "A6");
			Assert.IsTrue (p.ThrowOnErrorDeserializing, "A7");
			Assert.IsFalse (p.ThrowOnErrorSerializing, "A8");
			Assert.IsTrue (p.IsReadOnly, "A9");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:SettingsPropertyTest.cs


示例19: Properties

		public void Properties ()
		{
			SettingsProperty p = new SettingsProperty ("property",
								   typeof (int),
								   null,
								   true,
								   10,
								   SettingsSerializeAs.String,
								   null,
								   true,
								   false);

			SettingsPropertyValue v = new SettingsPropertyValue (p);

			Assert.IsFalse (v.Deserialized, "A1");
			Assert.IsFalse (v.IsDirty, "A2");
			Assert.AreEqual ("property", v.Name, "A3");
			Assert.AreEqual (p, v.Property, "A4");
			Assert.AreEqual ((object)10, v.PropertyValue, "A5");
			Assert.AreEqual (null, v.SerializedValue, "A6");
			Assert.IsTrue (v.UsingDefaultValue, "A7");

			/* test that setting v.PropertyValue to
			 * something else causes SerializedValue to
			 * become not-null */
			v.PropertyValue = (object)5;
			Assert.AreEqual ("5", v.SerializedValue, "A9");

			/* test to see whether or not changing
			 * SerializeAs causes SerializedValue to
			 * change */
			p.SerializeAs = SettingsSerializeAs.Xml;
			Assert.AreEqual ("5", v.SerializedValue, "A11"); /* nope.. */

			/* only changing PropertyValue does */
			v.PropertyValue = (object)7;
			Assert.AreEqual ("<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<int>7</int>", ((string)v.SerializedValue).Replace ("\r\n", "\n"), "A13");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:38,代码来源:SettingsPropertyValueTest.cs


示例20: GivenConfirmedUsersWhenSetPropertyValuesWithInvalidColumnsThenThrowNotSupportedException

        public void GivenConfirmedUsersWhenSetPropertyValuesWithInvalidColumnsThenThrowNotSupportedException(
            string providerName, string membershipProviderName)
        {
            // arrange
            var testClass = this.WithProvider(providerName);
            var memProvider = this.WithMembershipProvider(membershipProviderName);
            var user = memProvider.WithConfirmedUser().Value;
            var context = new SettingsContext();
            context["UserName"] = user.UserName;
            var properties = new SettingsPropertyValueCollection
                                 {
                                     new SettingsPropertyValue(
                                         new SettingsProperty("invalidColumn")
                                             {
                                                 PropertyType = typeof(string)
                                             })
                                         {
                                             SerializedValue
                                                 =
                                                 "Value"
                                         }
                                 };
            if (memProvider.AsBetter().HasEmailColumnDefined)
            {
                var emailProperty = new SettingsProperty(memProvider.AsBetter().UserEmailColumn)
                                        {
                                            PropertyType =
                                                typeof(string)
                                        };
                properties.Add(
                    new SettingsPropertyValue(emailProperty) { PropertyValue = user.Email, Deserialized = true });
            }

            // act // assert
            Assert.Throws<NotSupportedException>(() => testClass.SetPropertyValues(context, properties));
        }
开发者ID:TheCodeKing,项目名称:BetterMembership.Net,代码行数:36,代码来源:GetAndSetPropertyTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Configuration.SettingsPropertyCollection类代码示例发布时间:2022-05-26
下一篇:
C# Configuration.SettingsContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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