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


C# SortedList.ContainsValue方法代码示例

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


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

示例1: OrderTablesByDependency

		/// <summary>
		/// Returns  List of tables ordered to allow inserts
		/// without violating constraints
		/// </summary>
		/// <param name="unorderedTables"></param>
		/// <returns></returns>
		public static SortedList OrderTablesByDependency( TableCollection unorderedTables)
		{
			ArrayList _referencedTables = new ArrayList();
			SortedList _sortedTables = new SortedList();

			//create a list of tables that are refernced by other tables
			foreach(Table tableObject in unorderedTables  )
			{
				if(tableObject.IsSystemObject) continue;
				
				foreach(string tableName in GetTableDependencies(tableObject))
				{
					if(!_referencedTables.Contains(tableName))
					{
						_referencedTables.Add(tableName);
					}
				}
			}
			//tables that are referenced have to be filled first
			while(true)
			{
				UpdateNonViolatingList(ref _referencedTables , ref _sortedTables ,ref unorderedTables);
				if(_referencedTables.Count == 0) break;
			}
			//tables that are not referenced at end
			foreach(Table tableObject in unorderedTables  )
			{
				if(tableObject.IsSystemObject) continue;

				if(!_sortedTables.ContainsValue(tableObject.Name))
				{
					_sortedTables.Add(_sortedTables.Count + 1 ,tableObject.Name );
				}
			}
			return _sortedTables;
		}
开发者ID:netordead,项目名称:SqlInserter,代码行数:42,代码来源:Utility.cs

示例2: TestContainsValue

		public void TestContainsValue ()
		{
			SortedList sl1 = new SortedList (55);
			sl1.Add (0, "zero");
			sl1.Add (1, "one");
			sl1.Add (2, "two");
			sl1.Add (3, "three");
			sl1.Add (4, "four");

			Assert.IsTrue (sl1.ContainsValue ("zero"), "#1");
			Assert.IsFalse (sl1.ContainsValue ("ohoo"), "#2");
			Assert.IsFalse (sl1.ContainsValue (null), "#3");
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:13,代码来源:SortedListTest.cs

示例3: TestGetEnumeratorBasic

        public void TestGetEnumeratorBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            //

            SortedList sl2 = null;

            IDictionaryEnumerator dicen = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            int i3 = 0;
            int i2 = 0;

            int i = 0;
            int j = 0;

            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //   Testcase: Set - null key, ArgExc expected
            Assert.Throws<ArgumentNullException>(() =>
                {
                    sl2[null] = 0;
                });

            Assert.Equal(0, sl2.Count);

            //   Testcase: Set - null val
            sl2[(object)100] = (object)null;
            Assert.Equal(1, sl2.Count);

            //   Testcase: vanila Set
            sl2[(object)100] = 1;
            Assert.Equal(1, sl2.Count);

            sl2.Clear();
            Assert.Equal(0, sl2.Count);

            //   Testcase: add key-val pairs
            for (i = 0; i < 100; i++)
            {
                sl2.Add(i + 100, i);
            }

            Assert.Equal(100, sl2.Count);

            for (i = 0; i < 100; i++)
            {
                j = i + 100;

                Assert.True(sl2.ContainsKey((int)j));
                Assert.True(sl2.ContainsValue(i));

                object o2 = sl2[(object)(j)]; //need to cast: Get (object key)
                Assert.NotNull(o2);
                i2 = (int)o2;

                i3 = (int)sl2.GetByIndex(i); //Get (index i)
                Assert.False((i3 != i) || (i2 != i));

                //  testcase: GetEnumerator
                dicen = (IDictionaryEnumerator)sl2.GetEnumerator();

                //  Boundary for Current
                Assert.Throws<InvalidOperationException>(() =>
                                 {
                                     object throwaway = dicen.Current;
                                 }
                );

                j = 0;
                //  go over the enumarator
                while (dicen.MoveNext())
                {
                    //  Current to see the order
                    i3 = (int)dicen.Value;
                    Assert.True(j.Equals(i3));

                    //  Current again to see the same order
                    i3 = (int)dicen.Value;
                    Assert.Equal(i3, j);

                    j++;
                }

                //  Boundary for Current
                Assert.Throws<InvalidOperationException>(() =>
                                 {
                                     object throwaway = dicen.Current;
//.........这里部分代码省略.........
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:GetEnumeratorTests.cs

示例4: RenderContents

		/// -----------------------------------------------------------------------------
		/// <summary>
		/// 
		/// </summary>
		/// <param name="writer"></param>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// 	[jbrinkman]	5/6/2004	Created
		///		[jhenning] 2/22/2005	Added properties
		/// </history>
		/// -----------------------------------------------------------------------------
		protected override void RenderContents(HtmlTextWriter writer)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
			writer.AddAttribute(HtmlTextWriterAttribute.Class, m_objMenu.CssClass);
			writer.AddAttribute(HtmlTextWriterAttribute.Name, m_objMenu.UniqueID);
			writer.AddAttribute(HtmlTextWriterAttribute.Id, m_objMenu.ClientID);

			writer.AddAttribute("orient", ((int)m_objMenu.Orientation).ToString());
			if (m_objMenu.SubMenuOrientation != Orientation.Vertical)
			{
				writer.AddAttribute("suborient", ((int)m_objMenu.SubMenuOrientation).ToString());
			}
			writer.AddAttribute("sysimgpath", m_objMenu.SystemImagesPath);
			if (!String.IsNullOrEmpty(m_objMenu.Target)) writer.AddAttribute("target", m_objMenu.Target); 

			//--- imagelist logic ---
			if (m_objMenu.ImageList.Count > 0)
			{
				SortedList objImagePaths = new SortedList();
				string strList = "";
				string strImagePathList = "";
				foreach (NodeImage objNodeImage in m_objMenu.ImageList) {
					if (objNodeImage.ImageUrl.IndexOf("/") > -1)
					{
						string strPath = objNodeImage.ImageUrl.Substring(0, objNodeImage.ImageUrl.LastIndexOf("/") + 1);
						string strImage = objNodeImage.ImageUrl.Substring(objNodeImage.ImageUrl.LastIndexOf("/") + 1);
						if (objImagePaths.ContainsValue(strPath) == false)
						{
							objImagePaths.Add(objImagePaths.Count, strPath);
						}
						objNodeImage.ImageUrl = string.Format("[{0}]{1}", objImagePaths.IndexOfValue(strPath).ToString(), strImage);
					}
                        strList += (String.IsNullOrEmpty(strList) ? "" : ",") + objNodeImage.ImageUrl;
				}
				for (int intPaths = 0; intPaths <= objImagePaths.Count - 1; intPaths++) 
                    {
                        strImagePathList += (String.IsNullOrEmpty(strImagePathList) ? "" : ",") + objImagePaths.GetByIndex(intPaths).ToString();
				}
				writer.AddAttribute("imagelist", strList);
				writer.AddAttribute("imagepaths", strImagePathList);
			}

			//--- urllist logic ---'
			//Dim objUsedTokens As ArrayList = New ArrayList
			//Me.AssignUrlTokens(m_objMenu.MenuNodes, Nothing, objUsedTokens)
			//If objUsedTokens.Count > 0 Then
			//	writer.AddAttribute("urllist", Join(objUsedTokens.ToArray(), ","))				  'comma safe?!?!?!
			//End If

			if (!String.IsNullOrEmpty(m_objMenu.RootArrowImage)) writer.AddAttribute("rarrowimg", m_objMenu.RootArrowImage); 
			if (!String.IsNullOrEmpty(m_objMenu.ChildArrowImage)) writer.AddAttribute("carrowimg", m_objMenu.ChildArrowImage); 
			if (!String.IsNullOrEmpty(m_objMenu.WorkImage)) writer.AddAttribute("workimg", m_objMenu.WorkImage); 

			//css attributes
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClass)) writer.AddAttribute("css", m_objMenu.DefaultNodeCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultChildNodeCssClass)) writer.AddAttribute("csschild", m_objMenu.DefaultChildNodeCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClassOver)) writer.AddAttribute("csshover", m_objMenu.DefaultNodeCssClassOver); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClassSelected)) writer.AddAttribute("csssel", m_objMenu.DefaultNodeCssClassSelected); 
			if (!String.IsNullOrEmpty(m_objMenu.MenuBarCssClass)) writer.AddAttribute("mbcss", m_objMenu.MenuBarCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.MenuCssClass)) writer.AddAttribute("mcss", m_objMenu.MenuCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultIconCssClass)) writer.AddAttribute("cssicon", m_objMenu.DefaultIconCssClass); 

			if (!String.IsNullOrEmpty(m_objMenu.JSFunction)) writer.AddAttribute("js", m_objMenu.JSFunction); 
			if (m_objMenu.UseTables == false) writer.AddAttribute("usetables", "0"); 
			if (m_objMenu.EnablePostbackState) writer.AddAttribute("enablepbstate", "1"); 
			if (m_objMenu.MouseOutDelay != 500) writer.AddAttribute("moutdelay", m_objMenu.MouseOutDelay.ToString()); 
			if (m_objMenu.MouseInDelay != 250) writer.AddAttribute("mindelay", m_objMenu.MouseInDelay.ToString()); 

			writer.AddAttribute("postback", ClientAPI.GetPostBackEventReference(m_objMenu, "[NODEID]" + ClientAPI.COLUMN_DELIMITER + "Click"));

			if (m_objMenu.PopulateNodesFromClient)
			{
				if (DotNetNuke.UI.Utilities.ClientAPI.BrowserSupportsFunctionality(Utilities.ClientAPI.ClientFunctionality.XMLHTTP))
				{
					writer.AddAttribute("callback", DotNetNuke.UI.Utilities.ClientAPI.GetCallbackEventReference(m_objMenu, "'[NODEXML]'", "this.callBackSuccess", "oMNode", "this.callBackFail", "this.callBackStatus"));
				}
				else
				{
					writer.AddAttribute("callback", ClientAPI.GetPostBackClientHyperlink(m_objMenu, "[NODEID]" + ClientAPI.COLUMN_DELIMITER + "OnDemand"));
				}
				if (!String.IsNullOrEmpty(m_objMenu.CallbackStatusFunction))
				{
					writer.AddAttribute("callbacksf", m_objMenu.CallbackStatusFunction);
				}

			}

			if (!String.IsNullOrEmpty(m_objMenu.JSFunction))
//.........这里部分代码省略.........
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:101,代码来源:DNNMenuUpLevelWriter.cs

示例5: OnActivateTool

    /// <summary>
    /// Called when the tool is activated.
    /// </summary>
    protected override void OnActivateTool() {
      if (this.Controller.Model.Selection.SelectedItems != null && this.Controller.Model.Selection.SelectedItems.Count > 0) {
        /*
       * They should give me a Nobel prize for so much thinking early in the morning...
       */
        #region Preparation of the ordering
        Debug.Assert(this.Controller.Model.Selection.SelectedItems[0] != null, "A selection cannot contain a 'null' entity.");
        //the items have to be moved in the order of the Paintables; the SortedList automatically orders things for us.
        SortedList<int, IDiagramEntity> list = new SortedList<int, IDiagramEntity>();
        //We fetch a flattened selection, which means that if there is a group the constituents will be
        //returned rather than the group itself.
        foreach (IDiagramEntity entity in this.Controller.Model.Selection.FlattenedSelectionItems) {
          //the addition will automatically put the item in increasing order
          list.Add(this.Controller.Model.Paintables.IndexOf(entity), entity);
        }
        //if the lowest z-value is the first one in the paintables we cannot shift anything, so we quit
        if (list.Keys[0] == 0) return;

        /*Send them forwards but make sure it's a visible effect!
        It's not enough to move it only once since the shape(s) above might be of
        high z-order degree, so we have to find which is the first shape overlapping with 
        the selection and take as many steps as it takes to surpass it.
         If there is no overlap we'll shift the z-order with just one unit.
        */
        int delta = 1;
        int lowestZInSelection = list.Keys[0];
        bool found = false;
        //we can speed up the loop by noticing that the previous shape in the z-stack is necessarily
        //below the first one of the selection
        for (int m = lowestZInSelection - 1; m >= 0 && !found; m--) {
          //the overlap has to be with an entity, not from the selection
          if (list.ContainsValue(this.Controller.Model.Paintables[m])) continue;
          for (int s = 0; s < list.Count; s++) {
            //if there is an overlap we found the required index
            if (this.Controller.Model.Paintables[m].Rectangle.IntersectsWith(list.Values[s].Rectangle)) {
              //an additional complication here; if the found shape is part of a group we have
              //to take the upper z-value of the group...
              if (this.Controller.Model.Paintables[m].Group != null) {
                int min = int.MaxValue;
                CollectionBase<IDiagramEntity> leafs = new CollectionBase<IDiagramEntity>();
                Utils.TraverseCollect(this.Controller.Model.Paintables[m].Group, ref leafs);
                foreach (IDiagramEntity groupMember in leafs) {
                  min = Math.Min(min, this.Controller.Model.Paintables.IndexOf(groupMember));
                }
                //take the found z-value of the group rather than the one of the group-child
                m = min;
              }
              delta = lowestZInSelection - m;
              found = true;
              break;
            }

          }
        }
        #endregion
        Debug.Assert(delta >= 1, "The shift cannot be less than one since we checked previous situations earlier.");
        for (int k = 0; k < list.Count; k++) {
          this.Controller.Model.SendBackwards(list.Values[k], delta);
        }
      }
      DeactivateTool();
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:65,代码来源:SendBackwardsTool.cs

示例6: TestGetValueListBasic

        public void TestGetValueListBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            SortedList sl2 = null;
            IEnumerator en = null;
            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            int i3 = 0;
            int i = 0;
            int j = 0;
            //
            // Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList();

            // Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            // Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            // Testcase: Set - null key, ArgExc expected
            Assert.Throws<ArgumentNullException>(() =>
                {
                    sl2[null] = 0;
                });

            Assert.Equal(0, sl2.Count);

            // Testcase: Set - null val
            sl2[(object)100] = (object)null;
            Assert.Equal(1, sl2.Count);

            // Testcase: vanila Set
            sl2[(object)100] = 1;
            Assert.Equal(1, sl2.Count);
            sl2.Clear();
            Assert.Equal(0, sl2.Count);

            // Testcase: add key-val pairs
            for (i = 0; i < 100; i++)
            {
                sl2.Add(i + 100, i);
            }
            Assert.Equal(100, sl2.Count);

            for (i = 0; i < 100; i++)
            {
                j = i + 100;
                Assert.True(sl2.ContainsKey((int)j));
                Assert.True(sl2.ContainsValue(i));

                object o2 = sl2[(int)j];

                Assert.NotNull(o2);
                Assert.True(o2.Equals(i), "Error, entry for key " + j.ToString() + " is " + o2.ToString() + " but should have been " + i.ToString());
            } // FOR

            //  testcase: GetValueList
            // ICollection.GetEnumerator() first test the boundaries on the Remove method thru GetEnumerator implementation
            en = (IEnumerator)sl2.GetValueList().GetEnumerator();

            // Boundary for Current
            Assert.Throws<InvalidOperationException>(() =>
                    {
                        object throwaway = en.Current;
                    }
            );

            j = 0;
            // go over the enumarator
            en = (IEnumerator)sl2.GetValueList().GetEnumerator();
            while (en.MoveNext())
            {
                // Current to see the order
                i3 = (int)en.Current;
                Assert.Equal(i3, j);

                // GetObject again to see the same order
                i3 = (int)en.Current;
                Assert.Equal(i3, j);

                j++;
            }

            // Boundary for GetObject
            Assert.Throws<InvalidOperationException>(() =>
                    {
                        object throwawayobj = en.Current;
                    }
            );

            // Boundary for MoveNext: call MoveNext to make sure it returns false
            Assert.False((en.MoveNext()) || (j != 100));
            // call again MoveNext to make sure it still returns false
            Assert.False(en.MoveNext());
            Assert.Equal(100, sl2.Count);
//.........这里部分代码省略.........
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:GetValueListTests.cs

示例7: TestGetKeyListBasic

        public void TestGetKeyListBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            //

            SortedList sl2 = null;
            IEnumerator en = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            int i3 = 0;
            int i = 0;
            int j = 0;

            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(); //using default IComparable implementation from Integer4
            // which is used here as key-val elements.

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //   Testcase: Set - null key, ArgExc expected
            Assert.Throws<ArgumentNullException>(() =>
                {
                    sl2[null] = 0;
                });

            Assert.Equal(0, sl2.Count);

            //   Testcase: Set - null val
            sl2[(Object)100] = (Object)null;
            Assert.Equal(1, sl2.Count);

            //   Testcase: vanila Set
            sl2[(Object)100] = 1;
            Assert.Equal(1, sl2.Count);

            sl2.Clear();
            Assert.Equal(0, sl2.Count);

            //   Testcase: add key-val pairs
            for (i = 0; i < 100; i++)
            {
                sl2.Add(i + 100, i);
            }

            Assert.Equal(100, sl2.Count);

            for (i = 0; i < 100; i++)
            {
                j = i + 100;
                Assert.True(sl2.ContainsKey((int)j));
                Assert.True(sl2.ContainsValue(i));
            }

            //  testcase: GetKeyList
            //  first test the boundaries on the Remove method thru GetEnumerator implementation
            en = (IEnumerator)sl2.GetKeyList().GetEnumerator();

            //  Boundary for Current
            Assert.Throws<InvalidOperationException>(() =>
                             {
                                 Object objThrowAway = en.Current;
                             }
            );

            j = 100;
            //  go over the enumarator
            en = (IEnumerator)sl2.GetKeyList().GetEnumerator();
            while (en.MoveNext())
            {
                //  Current to see the order
                i3 = (int)en.Current;
                Assert.Equal(i3, j);

                //  Current again to see the same order
                i3 = (int)en.Current;
                Assert.Equal(i3, j);

                j++;
            }


            //  Boundary for Current
            Assert.Throws<InvalidOperationException>(() =>
                             {
                                 Object objThrowAway = en.Current;
                             }
            );

            //  Boundary for MoveNext: call MoveNext to make sure it returns false
            Assert.False((en.MoveNext()) || (j != 200));

//.........这里部分代码省略.........
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:GetKeyListTests.cs

示例8: TestContainsValue

	public void TestContainsValue() {
		SortedList sl1 = new SortedList(55);
                sl1.Add(0, "zero");
                sl1.Add(1, "one");
                sl1.Add(2, "two");
                sl1.Add(3, "three");
                sl1.Add(4, "four");

		Assert("sl.ContainsValue: can't find existing value", sl1.ContainsValue("zero"));
		Assert("sl.ContainsValue: finds non-existing value", !sl1.ContainsValue("ohoo"));
		Assert("sl.ContainsValue: finds non-existing value", !sl1.ContainsValue(null));
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:SortedListTest.cs

示例9: TestContainsValueBasic

        public void TestContainsValueBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            SortedList sl2 = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            String s1 = null;
            String s2 = null;
            int i = 0;
            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //   Testcase: No_Such_Key
            Assert.False(sl2.ContainsKey("No_Such_Val"));

            //   Testcase: add few key-val pairs
            for (i = 0; i < 100; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                sl2.Add(s1, s2);
            }
            //
            //   Testcase: test ContainsValue
            //
            for (i = 0; i < sl2.Count; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                Assert.True(sl2.ContainsValue(s2));
            }

            //
            // Remove a key and then check
            //
            sblMsg.Length = 0;
            sblMsg.Append("key_50");
            s1 = sblMsg.ToString();

            sl2.Remove(s1); //removes "Key_50"

            sblMsg.Length = 0;
            sblMsg.Append("val_50");
            s2 = sblMsg.ToString();

            Assert.False(sl2.ContainsKey(s2));
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:70,代码来源:ContainsValueTests.cs

示例10: TestGetSyncRootBasic

        public void TestGetSyncRootBasic()
        {
            SortedList arrSon;
            SortedList arrMother;

            Task[] workers;
            Action ts1;
            Action ts2;
            Int32 iNumberOfWorkers = 4;

            SortedList hshPossibleValues;
            IDictionaryEnumerator idic;

            // Vanila test case - testing SyncRoot is not as simple as its implementation looks like. This is the working
            //scenrio we have in mind.
            //1) Create your Down to earth mother SortedList
            //2) Get a synchronized wrapper from it
            //3) Get a Synchronized wrapper from 2)
            //4) Get a synchronized wrapper of the mother from 1)
            //5) all of these should SyncRoot to the mother earth

            arrMother = new SortedList();
            for (int i = 0; i < _iNumberOfElements; i++)
            {
                arrMother.Add("Key_" + i, "Value_" + i);
            }

            Assert.Equal(arrMother.SyncRoot.GetType(), typeof(Object));

            arrSon = SortedList.Synchronized(arrMother);
            _arrGrandDaughter = SortedList.Synchronized(arrSon);
            _arrDaughter = SortedList.Synchronized(arrMother);

            Assert.Equal(arrSon.SyncRoot, arrMother.SyncRoot);

            Assert.Equal(arrSon.SyncRoot, arrMother.SyncRoot);

            Assert.Equal(_arrGrandDaughter.SyncRoot, arrMother.SyncRoot);

            Assert.Equal(_arrDaughter.SyncRoot, arrMother.SyncRoot);

            Assert.Equal(arrSon.SyncRoot, arrMother.SyncRoot);

            //we are going to rumble with the SortedLists with some threads

            workers = new Task[iNumberOfWorkers];
            ts2 = new Action(RemoveElements);
            for (int iThreads = 0; iThreads < iNumberOfWorkers; iThreads += 2)
            {
                var name = "Thread_worker_" + iThreads;
                ts1 = new Action(() => AddMoreElements(name));

                workers[iThreads] = Task.Run(ts1);
                workers[iThreads + 1] = Task.Run(ts2);
            }

            Task.WaitAll(workers);

            //checking time
            //Now lets see how this is done.
            //Either there are some elements or none
            hshPossibleValues = new SortedList();
            for (int i = 0; i < _iNumberOfElements; i++)
            {
                hshPossibleValues.Add("Key_" + i, "Value_" + i);
            }
            for (int i = 0; i < iNumberOfWorkers; i++)
            {
                hshPossibleValues.Add("Key_Thread_worker_" + i, "Thread_worker_" + i);
            }

            //lets check the values if
            idic = arrMother.GetEnumerator();
            while (idic.MoveNext())
            {
                Assert.True(hshPossibleValues.ContainsKey(idic.Key), "Error, Expected value not returned, " + idic.Key);
                Assert.True(hshPossibleValues.ContainsValue(idic.Value), "Error, Expected value not returned, " + idic.Value);
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:79,代码来源:PropertySyncRootTests.cs

示例11: GetHtmlInstructionTable

        public static string GetHtmlInstructionTable()
        {
            string result = "";

            result +=
                @"
                <TABLE BORDER=""1"" ALIGN=""CENTER"" WIDTH=""100%"" rules=""all"" frame=""box"" cellspacing=""0"" cellpadding=""0"" bordercolor=""#A0A0A0"">
                    <THEAD bgcolor=""#C0C0C0"">
                        <TH style=""border-left: thin"">Simple</TH>
                        <TH style=""border-left: thin"">IL</TH>
                        <TH style=""border-left: thin"">Param</TH>
                    </THEAD>

                    <TBODY>
                ";

            string[] paramTypes = new string[10]
                                                                {
                                                                    "none",
                                                                    "Int32",
                                                                    "Int32",
                                                                    "Int64",
                                                                    "Int32",
                                                                    "Int32",
                                                                    "double",
                                                                    "double",
                                                                    "(reflection object)",
                                                                    "Int32[]"
                                                                };

            for (InstructionCode code = InstructionCode.ADD; code <= InstructionCode.XOR; code++)
            {
                SortedList hash = new SortedList();

                int i;
                string il = "", parms = "";
                for (i = 0; i < instructions.Length; i++)
                    if (instructions[i].code == code && instructions[i].name != "-")
                    {
                        il += instructions[i].name+" ";

                        ParamType pType = instructions[i].pType;
                        string pTypeStr = paramTypes[(int)pType];
                        if (pType != ParamType.pNone && ! hash.ContainsValue(pTypeStr))
                            hash.Add(i,pTypeStr);
                    }

                for (i = 0; i < hash.Count; i++)
                    parms += hash.GetByIndex(i)+" ";

                result += "                        <TR>\n";

                result += @"                            <TD style=""border-left: thin; border-top: thin"" align=""left"">"+code+"</TD>";
                result += @"                            <TD style=""border-left: thin; border-top: thin"" align=""left"">"+il+"</TD>";
                result += @"                            <TD style=""border-left: thin; border-top: thin"" align=""left"">"+parms+"</TD>";

                result += "                        </TR>\n";
            }

            result +=
                @"
                    </TBODY>
                </TABLE>
                ";

            return result;
        }
开发者ID:DragonXYZ,项目名称:cilpe,代码行数:67,代码来源:Instructions.cs


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