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


C# SettingsPropertyCollection.Remove方法代碼示例

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


在下文中一共展示了SettingsPropertyCollection.Remove方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Remove

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

			col.Add (test_prop);

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

			col.Remove ("test_prop");

			Assert.AreEqual (0, col.Count, "A2");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:13,代碼來源:SettingsPropertyCollectionTest.cs

示例2: PropertyValuesInitialized

		public void PropertyValuesInitialized ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();
			int i;

			try {
				i = s.Foo;
				Assert.Fail ("#1-2");
			} catch (SettingsPropertyNotFoundException) {
			}

			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#2-1");
			Assert.AreEqual (0, s.Context.Count, "#2-2");

			props.Add (new SettingsProperty ("Foo", typeof (int), p, false, 10, SettingsSerializeAs.String, null, true, true));
			// initialize w/o the provider
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#3-0");
			Assert.AreEqual (100, s.Foo, "#3-1");
			// ... !!!
			Assert.AreEqual (1, s.PropertyValues.Count, "#3-2");
			SettingsPropertyValue v = s.PropertyValues ["Foo"];
			Assert.AreEqual (100, v.PropertyValue, "#3-3");
			Assert.AreEqual (0, s.Context.Count, "#3-4");

			// initialize w/ the provider
			provs.Add (p);
			provs.Add (new MyProvider2 ("Bar", 25));
			props.Add (new SettingsProperty ("Bar", typeof (int), provs ["MyProvider2"], false, 10, SettingsSerializeAs.String, null, true, true));
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (1, s.PropertyValues.Count, "#4-1");
			Assert.AreEqual (100, s.Foo, "#4-2");
			Assert.AreEqual (25, s.Bar, "#4-3");
			// ... !!!
			Assert.AreEqual (2, s.PropertyValues.Count, "#4-3-2");
			Assert.AreEqual (0, s.Context.Count, "#4-4");

			// wrong provider
			props.Remove ("Bar");
			props.Add (new SettingsProperty ("Bar", typeof (int), provs ["MyProvider"], false, 10, SettingsSerializeAs.String, null, true, true));
			s = new MySettings ();
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#5-1");
			Assert.AreEqual (100, s.Foo, "#5-2");
			Assert.AreEqual (10, s.Bar, "#5-3");
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:51,代碼來源:SettingsBaseTest.cs

示例3: ReadOnly_Remove

		public void ReadOnly_Remove ()
		{
			SettingsPropertyCollection col = new SettingsPropertyCollection ();

			SettingsProperty test_prop = new SettingsProperty ("test_prop");
			col.Add (test_prop);

			col.SetReadOnly ();

			col.Remove ("test_prop");
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:11,代碼來源:SettingsPropertyCollectionTest.cs

示例4: GetPropertyValues

        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
        {
            var result = new SettingsPropertyValueCollection();

              if (!this.Initialized)
              {
            return result;
              }

              string userName = (string)context["UserName"];

              if (string.IsNullOrEmpty(userName) || userName.Contains(@"\"))
              {
            return result;
              }

              var relevantProperties = this.GetRelevantProperties(collection);
              if (relevantProperties.Count == 0)
              {
            return result;
              }

              var userProperties = this.GetProperties(userName, this.SaleforcePropertyNames);

              foreach (SalesforceProfileProperty property in relevantProperties)
              {
            object value;
            if (userProperties.TryGetValue(property.SalesforceName, out value))
            {
              value = this.ConvertProperty(value, property.PropertyType);
            }

            result.Add(new SettingsPropertyValue(property)
              {
            IsDirty = false,
            PropertyValue = value,
              });

            collection.Remove(property.Name);
              }

              return result;
        }
開發者ID:clone278,項目名稱:sitecore-salesforce-connect,代碼行數:43,代碼來源:SalesforceProfileProvider.cs


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