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


C# ReadOnlyCollection.GetEnumerator方法代码示例

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


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

示例1: SelectOption

        public bool SelectOption(ReadOnlyCollection<IWebElement> fromOptions, string selectThis, bool setSelected, bool allowMultipleSelect)
        {
            bool matchMade = false;
            IEnumerator<IWebElement> allOptions = fromOptions.GetEnumerator();

            while (allOptions.MoveNext())
            {
                IWebElement option = allOptions.Current;
                bool matchThisTime = SelectOption(option, selectThis);
                if (matchThisTime)
                {
                    if (setSelected)
                    {
                        option.Select();
                    }
                    else if (option.Selected)
                    {
                        option.Toggle();
                    }
                }

                matchMade |= matchThisTime;
                if (matchMade && !allowMultipleSelect)
                {
                    return true;
                }
            }

            return matchMade;
        }
开发者ID:hugs,项目名称:selenium,代码行数:30,代码来源:BaseOptionSelectStragety.cs

示例2: SaveToFile

 /// <summary>
 /// Save a collection of ClipData to HardDisk
 /// </summary>
 /// <param name="clipData">The collection of ClipData to save</param>
 /// <param name="clipName">The name of the file</param>
 public static void SaveToFile(ReadOnlyCollection<DataClip> clipData, string clipName)
 {
     //Get the enumeration of the clipboard data
     IEnumerator<DataClip> cData = clipData.GetEnumerator();
     //Init a counter
     int i = 0;
     //Delete the folder, if already exists
     if (Directory.Exists(clipName))
     {
         Directory.Delete(clipName,true);
     }
     //Open the directory on which save the files
     DirectoryInfo di= Directory.CreateDirectory(clipName);
     
     while (cData.MoveNext())
     {
         //Init the serializer
         XmlSerializer xml = new XmlSerializer(typeof(DataClip));
         // To write to a file, create a StreamWriter object.
         using (StreamWriter sw = new StreamWriter(di.FullName + @"\" + i.ToString() + ".cli",false))
         {
             //Serialize the clipboard data
             xml.Serialize(sw, cData.Current);
         }
         
         i++;
     }
  }
开发者ID:dixonte,项目名称:STC.Automation.Office,代码行数:33,代码来源:ClipboardHelper.cs

示例3: SetClipboard

        /// <summary>
        /// Empty the Clipboard and Restore to system clipboard data contained in a collection of ClipData objects
        /// </summary>
        /// <param name="clipData">The collection of ClipData containing data stored from clipboard</param>
        /// <returns></returns>    
        public static bool SetClipboard(ReadOnlyCollection<DataClip> clipData)
        {
            //Open clipboard to allow its manipultaion
            if (!Win32ClipboardAPI.OpenClipboard(IntPtr.Zero))
                return false;
            
            //Clear the clipboard
            EmptyClipboard();
                        
            //Get an Enumerator to iterate into each ClipData contained into the collection
            IEnumerator<DataClip> cData = clipData.GetEnumerator();
            while( cData.MoveNext())
            {
                DataClip cd = cData.Current;

                //Get the pointer for inserting the buffer data into the clipboard
                IntPtr alloc = Win32MemoryAPI.GlobalAlloc(Win32MemoryAPI.GMEM_MOVEABLE | Win32MemoryAPI.GMEM_DDESHARE, cd.Size);
                IntPtr gLock = Win32MemoryAPI.GlobalLock(alloc);

                //Clopy the buffer of the ClipData into the clipboard
                if ((int)cd.Size>0)
                {
                    Marshal.Copy(cd.Buffer, 0, gLock, cd.Buffer.GetLength(0));
                }
                else
                {
                }
                //Release pointers 
                Win32MemoryAPI.GlobalUnlock(alloc);
                Win32ClipboardAPI.SetClipboardData(cd.Format, alloc);
            };
            //Close the clipboard to realese unused resources
            Win32ClipboardAPI.CloseClipboard();
            return true;
        }
开发者ID:dixonte,项目名称:STC.Automation.Office,代码行数:40,代码来源:ClipboardHelper.cs

示例4: ReadOnlySet_getEnumerator

        public void ReadOnlySet_getEnumerator()
        {
            List<Int32> source = new List<Int32>();
            ReadOnlyCollection<Int32> actual = new ReadOnlyCollection<int>( source );

            Assert.IsNotNull( actual.GetEnumerator() );
        }
开发者ID:RadicalFx,项目名称:Radical,代码行数:7,代码来源:ReadOnlySetTest.cs

示例5: TestCollection

        public void TestCollection()
        {
            // Default ctor.
            var data = Enumerable.Range(1, 5).ToArray();
            var col = new ReadOnlyCollection<int>(data);

            Assert.AreEqual(5, col.Count);
            Assert.IsTrue(col.IsReadOnly);
            CollectionAssert.AreEqual(data, col);

            Assert.IsTrue(col.GetEnumerator().MoveNext());
            Assert.IsTrue(((IEnumerable) col).GetEnumerator().MoveNext());

            Assert.IsTrue(col.Contains(4));

            var arr = new int[5];
            col.CopyTo(arr, 0);
            CollectionAssert.AreEqual(data, arr);

            Assert.Throws<NotSupportedException>(() => col.Add(1));
            Assert.Throws<NotSupportedException>(() => col.Clear());
            Assert.Throws<NotSupportedException>(() => col.Remove(1));
        }
开发者ID:kjniemi,项目名称:ignite,代码行数:23,代码来源:ReadOnlyCollectionTest.cs

示例6: CheckIfBookmarkExistInCollection

		private bool CheckIfBookmarkExistInCollection(string bookmarkName, ReadOnlyCollection<BookmarkInfo> bookmarks)
		{
			bool flag;
			IEnumerator<BookmarkInfo> enumerator = bookmarks.GetEnumerator();
			using (enumerator)
			{
				while (enumerator.MoveNext())
				{
					BookmarkInfo current = enumerator.Current;
					if (bookmarkName != current.BookmarkName)
					{
						continue;
					}
					flag = true;
					return flag;
				}
				return false;
			}
			return flag;
		}
开发者ID:nickchal,项目名称:pash,代码行数:20,代码来源:PSWorkflowApplicationInstance.cs


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