當前位置: 首頁>>代碼示例>>C#>>正文


C# Configuration.SettingsProperty類代碼示例

本文整理匯總了C#中System.Configuration.SettingsProperty的典型用法代碼示例。如果您正苦於以下問題:C# SettingsProperty類的具體用法?C# SettingsProperty怎麽用?C# SettingsProperty使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SettingsProperty類屬於System.Configuration命名空間,在下文中一共展示了SettingsProperty類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的System.Configuration.SettingsProperty類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。