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


C# ListDictionary.Remove方法代码示例

本文整理汇总了C#中System.Collections.Specialized.ListDictionary.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ListDictionary.Remove方法的具体用法?C# ListDictionary.Remove怎么用?C# ListDictionary.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Specialized.ListDictionary的用法示例。


在下文中一共展示了ListDictionary.Remove方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BasicTests

		private void BasicTests (ListDictionary ld)
		{
			Assert.AreEqual (0, ld.Count, "Count");
			Assert.IsFalse (ld.IsFixedSize, "IsFixedSize");
			Assert.IsFalse (ld.IsReadOnly, "IsReadOnly");
			Assert.IsFalse (ld.IsSynchronized, "IsSynchronized");
			Assert.AreEqual (0, ld.Keys.Count, "Keys");
			Assert.AreEqual (0, ld.Values.Count, "Values");
			Assert.IsNotNull (ld.SyncRoot, "SyncRoot");
			Assert.IsNotNull (ld.GetEnumerator (), "GetEnumerator");
			Assert.IsNotNull ((ld as IEnumerable).GetEnumerator (), "IEnumerable.GetEnumerator");

			ld.Add ("a", "1");
			Assert.AreEqual (1, ld.Count, "Count-1");
			Assert.IsTrue (ld.Contains ("a"), "Contains(a)");
			Assert.IsFalse (ld.Contains ("1"), "Contains(1)");

			ld.Add ("b", null);
			Assert.AreEqual (2, ld.Count, "Count-2");
			Assert.IsNull (ld["b"], "this[b]");

			DictionaryEntry[] entries = new DictionaryEntry[2];
			ld.CopyTo (entries, 0);

			ld["b"] = "2";
			Assert.AreEqual ("2", ld["b"], "this[b]2");

			ld.Remove ("b");
			Assert.AreEqual (1, ld.Count, "Count-3");
			ld.Clear ();
			Assert.AreEqual (0, ld.Count, "Count-4");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:32,代码来源:ListDictionaryTest.cs

示例2: LoadSolution


//.........这里部分代码省略.........
						uitem = new UnknownSolutionItem () {
							FileName = projectPath,
							LoadError = e.Message,
						};
					}

					var h = new MSBuildHandler (projTypeGuid, projectGuid) {
						Item = uitem,
					};
					uitem.SetItemHandler (h);
					item = uitem;
				}

				MSBuildHandler handler = (MSBuildHandler) item.ItemHandler;
				projLines = lines.GetRange (sec.Start + 1, sec.Count - 2);
				DataItem it = GetSolutionItemData (projLines);

				handler.UnresolvedProjectDependencies = ReadSolutionItemDependencies (projLines);
				handler.SlnProjectContent = projLines.ToArray ();
				handler.ReadSlnData (it);

				if (!items.ContainsKey (projectGuid)) {
					items.Add (projectGuid, item);
					sortedList.Add (item);
					data.ItemsByGuid [projectGuid] = item;
				} else {
					monitor.ReportError (GettextCatalog.GetString ("Invalid solution file. There are two projects with the same GUID. The project {0} will be ignored.", projectPath), null);
				}
			}
			monitor.EndTask ();

			if (globals != null && globals.Contains ("NestedProjects")) {
				LoadNestedProjects (globals ["NestedProjects"] as Section, lines, items, monitor);
				globals.Remove ("NestedProjects");
			}

			// Resolve project dependencies
			foreach (var it in items.Values.OfType<SolutionEntityItem> ()) {
				MSBuildHandler handler = (MSBuildHandler) it.ItemHandler;
				if (handler.UnresolvedProjectDependencies != null) {
					foreach (var id in handler.UnresolvedProjectDependencies.ToArray ()) {
						SolutionItem dep;
						if (items.TryGetValue (id, out dep) && dep is SolutionEntityItem) {
							handler.UnresolvedProjectDependencies.Remove (id);
							it.ItemDependencies.Add ((SolutionEntityItem)dep);
						}
					}
					if (handler.UnresolvedProjectDependencies.Count == 0)
						handler.UnresolvedProjectDependencies = null;
				}
			}

			//Add top level folders and projects to the main folder
			foreach (SolutionItem ce in sortedList) {
				if (ce.ParentFolder == null)
					folder.Items.Add (ce);
			}

			//FIXME: This can be just SolutionConfiguration also!
			if (globals != null) {
				if (globals.Contains ("SolutionConfigurationPlatforms")) {
					LoadSolutionConfigurations (globals ["SolutionConfigurationPlatforms"] as Section, lines,
						sol, monitor);
					globals.Remove ("SolutionConfigurationPlatforms");
				}
开发者ID:riverans,项目名称:monodevelop,代码行数:66,代码来源:SlnFileFormat.cs

示例3: Remove

 public void Remove ()
 {
         ListDictionary ld = new ListDictionary ();
         ld.Remove (null);
 }
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:5,代码来源:ListDictionaryTest.cs

示例4: GetMembers

 public MemberInfo[] GetMembers(Type type)
 {
     Stack stack = new Stack();
     while (type != null)
     {
         stack.Push(type);
         type = type.BaseType;
     }
     IDictionary members = new ListDictionary();
     foreach (Type htype in stack)
     {
         foreach (MemberInfo member in htype.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance))
         {
             if (members.Contains(member.Name))
                 members.Remove(member.Name);
             members.Add(member.Name, member);
         }
     }
     return (MemberInfo[]) new ArrayList(members.Values).ToArray(typeof(MemberInfo));
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:20,代码来源:Discovery.cs

示例5: IsValidMarkup

        private bool IsValidMarkup(ContextProperty cp,
			Dimension.MeasureHyperCubeInfo mhci,
			ref ArrayList errors)
        {
            BuildValidMembersByDimension();
            ListDictionary instanceDimensionInfos = new ListDictionary();
            if (mhci.IsScenario)
            {
                foreach (Scenario sc in cp.Scenarios)
                {
                    if (sc.DimensionInfo != null)
                    {
                        instanceDimensionInfos[sc.DimensionInfo.dimensionId] = sc.DimensionInfo;
                    }
                }
            }
            else
            {
                //TODO: same thing for segments..
            }

            ListDictionary validationByDimension = new ListDictionary();

            int baseValidationData = 0;
            if (mhci.IsAllRelationShip)
            {
                baseValidationData += ValidationDataEnum.ALLRelationShip.GetHashCode();
            }
            else
            {
                baseValidationData += ValidationDataEnum.NotAllRelationShip.GetHashCode();

            }

            if (mhci.IsClosed)
            {
                baseValidationData += ValidationDataEnum.IsClosed.GetHashCode();

            }
            else
            {
                baseValidationData += ValidationDataEnum.IsNotClosed.GetHashCode();

            }

            foreach (DictionaryEntry de in validMembersByDimension)
            {
                int validationData = baseValidationData;
                bool found = false;
                bool hasDefault = false;

                ContextDimensionInfo cdi = instanceDimensionInfos[de.Key] as ContextDimensionInfo;
                instanceDimensionInfos.Remove(de.Key);
                if (cdi == null)
                {
                    validationData += ValidationDataEnum.DimensionNotInInstance.GetHashCode();
                }
                else
                {
                    HybridDictionary validMembers = de.Value as HybridDictionary;
                    if (validMembers != null)
                    {
                        found = validMembers[cdi.Id] != null;
                    }
                }

                if (found)
                {
                    validationData += ValidationDataEnum.Found.GetHashCode();

                }
                else
                {
                    validationData += ValidationDataEnum.NotFound.GetHashCode();

                }

                if (hasDefault)
                {
                    validationData += ValidationDataEnum.DimensionHasDefault.GetHashCode();

                    //TODO: determine if the default value is being used
                    //which is not a good thing and is an error condition.
                }

                ValidateResult(validationData, errors);

            }

            if (instanceDimensionInfos.Keys.Count != 0)
            {
                if (mhci.IsClosed)
                {
                    //this is an error condition as we have dimensions that are not part of
                    //the cube in the instance but the cube is a closed cube and does not
                    //allow other dimension infos
                    //TODO: enhance the error message...
                    string error = "Found invalid dimension for an element that is using a closed hypercube";

                    errors.Add(error);
//.........这里部分代码省略.........
开发者ID:plamikcho,项目名称:xbrlpoc,代码行数:101,代码来源:HypercubeHierarchy.cs

示例6: LoadSolution


//.........这里部分代码省略.........
						monitor.ReportWarning (GettextCatalog.GetString (
							"{0}({1}): Unsupported or unrecognized project : '{2}'.", 
							fileName, sec.Start + 1, projectPath));
						continue;
					}

					MSBuildProjectHandler handler = (MSBuildProjectHandler) item.ItemHandler;
					List<string> projLines = lines.GetRange (sec.Start + 1, sec.Count - 2);
					DataItem it = GetSolutionItemData (projLines);
					handler.SlnProjectContent = projLines.ToArray ();
					handler.ReadSlnData (it);
					
				} catch (Exception e) {
					if (e is UnknownSolutionItemTypeException) {
						var name = ((UnknownSolutionItemTypeException)e).TypeName;
						LoggingService.LogWarning (!string.IsNullOrEmpty (name)?
							  string.Format ("Could not load project '{0}' with unknown item type '{1}'", projectPath, name)
							: string.Format ("Could not load project '{0}' with unknown item type", projectPath));
						monitor.ReportWarning (!string.IsNullOrEmpty (name)?
							  GettextCatalog.GetString ("Could not load project '{0}' with unknown item type '{1}'", projectPath, name)
							: GettextCatalog.GetString ("Could not load project '{0}' with unknown item type", projectPath));
					} else {
						LoggingService.LogError (string.Format ("Error while trying to load the project {0}", projectPath), e);
						monitor.ReportWarning (GettextCatalog.GetString (
							"Error while trying to load the project '{0}': {1}", projectPath, e.Message));
					}

					var uitem = new UnknownSolutionItem () {
						FileName = projectPath,
						LoadError = e.Message,
					};
					var h = new MSBuildHandler (projTypeGuid, projectGuid) {
						Item = uitem,
					};
					uitem.SetItemHandler (h);
					item = uitem;
				}
				
				if (!items.ContainsKey (projectGuid)) {
					items.Add (projectGuid, item);
					sortedList.Add (item);
					data.ItemsByGuid [projectGuid] = item;
				} else {
					monitor.ReportError (GettextCatalog.GetString ("Invalid solution file. There are two projects with the same GUID. The project {0} will be ignored.", projectPath), null);
				}
			}
			monitor.EndTask ();

			if (globals != null && globals.Contains ("NestedProjects")) {
				LoadNestedProjects (globals ["NestedProjects"] as Section, lines, items, monitor);
				globals.Remove ("NestedProjects");
			}

			//Add top level folders and projects to the main folder
			foreach (SolutionItem ce in sortedList) {
				if (ce.ParentFolder == null)
					folder.Items.Add (ce);
			}

			//FIXME: This can be just SolutionConfiguration also!
			if (globals != null) {
				if (globals.Contains ("SolutionConfigurationPlatforms")) {
					LoadSolutionConfigurations (globals ["SolutionConfigurationPlatforms"] as Section, lines,
						sol, monitor);
					globals.Remove ("SolutionConfigurationPlatforms");
				}

				if (globals.Contains ("ProjectConfigurationPlatforms")) {
					LoadProjectConfigurationMappings (globals ["ProjectConfigurationPlatforms"] as Section, lines,
						sol, monitor);
					globals.Remove ("ProjectConfigurationPlatforms");
				}

				if (globals.Contains ("MonoDevelopProperties")) {
					LoadMonoDevelopProperties (globals ["MonoDevelopProperties"] as Section, lines,	sol, monitor);
					globals.Remove ("MonoDevelopProperties");
				}
				
				ArrayList toRemove = new ArrayList ();
				foreach (DictionaryEntry e in globals) {
					string name = (string) e.Key;
					if (name.StartsWith ("MonoDevelopProperties.")) {
						int i = name.IndexOf ('.');
						LoadMonoDevelopConfigurationProperties (name.Substring (i+1), (Section)e.Value, lines, sol, monitor);
						toRemove.Add (e.Key);
					}
				}
				foreach (object key in toRemove)
					globals.Remove (key);
			}

			//Save the global sections that we dont use
			List<string> globalLines = new List<string> ();
			foreach (Section sec in globals.Values)
				globalLines.InsertRange (globalLines.Count, lines.GetRange (sec.Start, sec.Count));

			data.GlobalExtra = globalLines;
			monitor.EndTask ();
			return folder;
		}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:101,代码来源:SlnFileFormat.cs

示例7: Test01

        public void Test01()
        {
            IntlStrings intl;
            ListDictionary ld;

            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aA",
                "text",
                "     SPaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            // keys for simple string values
            string[] keys =
            {
                "zero",
                "oNe",
                " ",
                "",
                "aa",
                "1",
                System.DateTime.Today.ToString(),
                "$%^#",
                Int32.MaxValue.ToString(),
                "     spaces",
                "2222222222222222222222222"
            };

            int cnt = 0;            // Count

            // initialize IntStrings
            intl = new IntlStrings();


            // [] ListDictionary is constructed as expected
            //-----------------------------------------------------------------

            ld = new ListDictionary();

            // [] Remove() on empty dictionary
            //
            cnt = ld.Count;
            Assert.Throws<ArgumentNullException>(() => { ld.Remove(null); });

            cnt = ld.Count;
            ld.Remove("some_string");
            if (ld.Count != cnt)
            {
                Assert.False(true, string.Format("Error, changed dictionary after Remove(some_string)"));
            }

            cnt = ld.Count;
            ld.Remove(new Hashtable());
            if (ld.Count != cnt)
            {
                Assert.False(true, string.Format("Error, changed dictionary after Remove(some_string)"));
            }

            // [] add simple strings and Remove()
            //

            cnt = ld.Count;
            int len = values.Length;
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != len)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, values.Length));
            }
            //

            for (int i = 0; i < len; i++)
            {
                cnt = ld.Count;
                ld.Remove(keys[i]);
                if (ld.Count != cnt - 1)
                {
                    Assert.False(true, string.Format("Error, returned: failed to remove item", i));
                }
                if (ld.Contains(keys[i]))
                {
                    Assert.False(true, string.Format("Error, removed wrong item", i));
                }
            }


            //
            // Intl strings
            // [] Add Intl strings and Remove()
//.........这里部分代码省略.........
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:RemoveObjTests.cs

示例8: Test01


//.........这里部分代码省略.........
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, len));
            }

            ks = ld.Keys;
            if (ks.Count != len)
            {
                Assert.False(true, string.Format("Error, returned Keys.Count = {0}", ks.Count));
            }
            arr = Array.CreateInstance(typeof(Object), len);
            ks.CopyTo(arr, 0);
            for (int i = 0; i < arr.Length; i++)
            {
                ind = Array.IndexOf(arr, intlValues[i + len]);
                if (ind < 0)
                {
                    Assert.False(true, string.Format("Error, Keys doesn't contain \"{1}\" key", i, intlValues[i + len]));
                }
            }

            //
            //   [] Change dictionary and verify Keys
            //

            ld.Clear();
            for (int i = 0; i < len; i++)
            {
                ld.Add(keys[i], values[i]);
            }
            if (ld.Count != len)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, len));
            }

            ks = ld.Keys;
            if (ks.Count != len)
            {
                Assert.False(true, string.Format("Error, returned Keys.Count = {0}", ks.Count));
            }

            ld.Remove(keys[0]);
            if (ld.Count != len - 1)
            {
                Assert.False(true, string.Format("Error, didn't remove element"));
            }
            if (ks.Count != len - 1)
            {
                Assert.False(true, string.Format("Error, Keys were not updated after removal"));
            }
            arr = Array.CreateInstance(typeof(Object), ld.Count);
            ks.CopyTo(arr, 0);
            ind = Array.IndexOf(arr, keys[0]);
            if (ind >= 0)
            {
                Assert.False(true, string.Format("Error, Keys still contains removed key " + ind));
            }

            ld.Add(keys[0], "new item");
            if (ld.Count != len)
            {
                Assert.False(true, string.Format("Error, didn't add element"));
            }
            if (ks.Count != len)
            {
                Assert.False(true, string.Format("Error, Keys were not updated after addition"));
            }
            arr = Array.CreateInstance(typeof(Object), ld.Count);
            ks.CopyTo(arr, 0);
            ind = Array.IndexOf(arr, keys[0]);
            if (ind < 0)
            {
                Assert.False(true, string.Format("Error, Keys doesn't contain added key "));
            }

            ICollection icol1;
            ListDictionary Hd = new ListDictionary();
            for (int i = 0; i < 10; i++)
                Hd.Add("key_" + i, "val_" + i);

            icol1 = Hd.Keys;

            if (Hd.SyncRoot != icol1.SyncRoot)
            {
                Assert.False(true, string.Format("Error, SyncRoot is not the same for ListDictionary's SyncRoot and ICollection.SyncRoot"));
            }

            // [] Run IEnumerable tests
            Hd = new ListDictionary();
            String[] expectedKeys = new String[10];
            for (int i = 0; i < 10; i++)
            {
                Hd.Add("key_" + i, "val_" + i);
                expectedKeys[i] = "key_" + i;
            }
            TestSupport.Collections.IEnumerable_Test iEnumerableTest;
            iEnumerableTest = new TestSupport.Collections.IEnumerable_Test(Hd.Keys, expectedKeys);
            if (!iEnumerableTest.RunAllTests())
            {
                Assert.False(true, string.Format("Err_98382apeuie System.Collections.IEnumerable tests FAILED"));
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:GetKeysTests.cs

示例9: Test01


//.........这里部分代码省略.........

            //
            //  Attempt to get Current should result in exception
            //
            Assert.Throws<InvalidOperationException>(() => { curr = (DictionaryEntry)en.Current; });

            //
            //  Attempt to get Entry should result in exception
            //
            Assert.Throws<InvalidOperationException>(() => { de = en.Entry; });

            //
            //   [] Modify dictionary when enumerating
            //
            if (ld.Count < 1)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    ld.Add(keys[i], values[i]);
                }
            }

            en = ld.GetEnumerator();
            res = en.MoveNext();
            if (!res)
            {
                Assert.False(true, string.Format("Error, MoveNext returned false"));
            }
            curr = (DictionaryEntry)en.Current;
            de = en.Entry;
            k = en.Key;
            v = en.Value;
            int cnt = ld.Count;
            ld.Remove(keys[0]);
            if (ld.Count != cnt - 1)
            {
                Assert.False(true, string.Format("Error, didn't remove item with 0th key"));
            }

            // will return just removed item
            DictionaryEntry curr2 = (DictionaryEntry)en.Current;
            if (!curr.Equals(curr2))
            {
                Assert.False(true, string.Format("Error, current returned different value after modification"));
            }

            // will return just removed item
            DictionaryEntry de2 = en.Entry;
            if (!de.Equals(de2))
            {
                Assert.False(true, string.Format("Error, Entry returned different value after modification"));
            }

            // will return just removed item
            Object k2 = en.Key;
            if (!k.Equals(k2))
            {
                Assert.False(true, string.Format("Error, Key returned different value after modification"));
            }

            // will return just removed item
            Object v2 = en.Value;
            if (!v.Equals(v2))
            {
                Assert.False(true, string.Format("Error, Value returned different value after modification"));
            }
开发者ID:noahfalk,项目名称:corefx,代码行数:67,代码来源:GetEnumeratorTests.cs

示例10: Test01

        public void Test01()
        {
            ListDictionary ld;

            // [] ListDictionary is constructed as expected
            //-----------------------------------------------------------------

            ld = new ListDictionary();


            if (ld == null)
            {
                Assert.False(true, string.Format("Error, dictionary is null after default ctor"));
            }

            if (ld.Count != 0)
            {
                Assert.False(true, string.Format("Error, Count = {0} after default ctor", ld.Count));
            }

            if (ld["key"] != null)
            {
                Assert.False(true, string.Format("Error, Item(some_key) returned non-null after default ctor"));
            }

            System.Collections.ICollection keys = ld.Keys;
            if (keys.Count != 0)
            {
                Assert.False(true, string.Format("Error, Keys contains {0} keys after default ctor", keys.Count));
            }

            System.Collections.ICollection values = ld.Values;
            if (values.Count != 0)
            {
                Assert.False(true, string.Format("Error, Values contains {0} items after default ctor", values.Count));
            }

            //
            // [] Add(string, string)
            //
            ld.Add("Name", "Value");
            if (ld.Count != 1)
            {
                Assert.False(true, string.Format("Error, Count returned {0} instead of 1", ld.Count));
            }
            if (String.Compare(ld["Name"].ToString(), "Value") != 0)
            {
                Assert.False(true, string.Format("Error, Item() returned unexpected value"));
            }

            //
            // [] Clear()
            //
            ld.Clear();
            if (ld.Count != 0)
            {
                Assert.False(true, string.Format("Error, Count returned {0} instead of 0 after Clear()", ld.Count));
            }
            if (ld["Name"] != null)
            {
                Assert.False(true, string.Format("Error, Item() returned non-null value after Clear()"));
            }

            //
            // [] elements not overriding Equals()
            //
            ld.Clear();
            Hashtable lbl = new Hashtable();
            Hashtable lbl1 = new Hashtable();
            ArrayList b = new ArrayList();
            ArrayList b1 = new ArrayList();
            ld.Add(lbl, b);
            ld.Add(lbl1, b1);
            if (ld.Count != 2)
            {
                Assert.False(true, string.Format("Error, Count returned {0} instead of 2", ld.Count));
            }
            if (!ld.Contains(lbl))
            {
                Assert.False(true, string.Format("Error, doesn't contain 1st special item"));
            }
            if (!ld.Contains(lbl1))
            {
                Assert.False(true, string.Format("Error, doesn't contain 2nd special item"));
            }
            if (ld.Values.Count != 2)
            {
                Assert.False(true, string.Format("Error, Values.Count returned {0} instead of 2", ld.Values.Count));
            }

            ld.Remove(lbl1);
            if (ld.Count != 1)
            {
                Assert.False(true, string.Format("Error, failed to remove item"));
            }
            if (ld.Contains(lbl1))
            {
                Assert.False(true, string.Format("Error, failed to remove special item"));
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:100,代码来源:CtorTests.cs


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