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


C# StringCollection.GetEnumerator方法代碼示例

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


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

示例1: CheckFileNameUsingPaths

 private static bool CheckFileNameUsingPaths(string fileName, StringCollection paths, out string fullFileName)
 {
     fullFileName = null;
     string str = fileName.Trim(new char[] { '"' });
     FileInfo info = new FileInfo(str);
     if (str.Length != info.Name.Length)
     {
         if (info.Exists)
         {
             fullFileName = info.FullName;
         }
         return info.Exists;
     }
     using (StringEnumerator enumerator = paths.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             string str3 = enumerator.Current + Path.DirectorySeparatorChar + str;
             FileInfo info2 = new FileInfo(str3);
             if (info2.Exists)
             {
                 fullFileName = str3;
                 return true;
             }
         }
     }
     return false;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:28,代碼來源:XomlCompilerHelper.cs

示例2: analyzeShortTermMemory

 public void analyzeShortTermMemory()
 {
     purifyBotsMind();
     StringCollection sc = new StringCollection();
     botsMemory.Clear();
     if(fullPathName == "")
         sc = readBrainFile();
     else
         sc = readBrainFile(fullPathName);
     StringEnumerator ii = sc.GetEnumerator();
     while(ii.MoveNext())
     {
         if(!botsMemory.Contains(parseForThoughts(ii.Current)))
             botsMemory.Add(parseForThoughts(ii.Current), parseForWords(ii.Current));
     }
     writeToLogFile("Number of memo entries", botsMemory.Count.ToString());
     memorySize = botsMemory.Count;
     return;
 }
開發者ID:sanyaade-g2g-repos,項目名稱:prelude-csharp,代碼行數:19,代碼來源:Mind.cs

示例3: Findfilepath

        /// <summary>
        /// Searches the StringCollection for the item's imagepath
        /// </summary>
        /// <param name="key">SL created key representing the Folder or Item</param>
        /// <param name="stringc">StringCollection of the current ImageLog file</param>
        /// <returns></returns>
        public static string Findfilepath(string key, StringCollection stringc)
        {
            string path = "";
            //Look for the entire line
            StringEnumerator SCE = stringc.GetEnumerator();
            while (SCE.MoveNext())
            {
                if (SCE.Current.Contains(key))
                    path = SCE.Current;
            }

            path = path.Substring(path.IndexOf(","), path.Length).Trim();

            return path;
        }
開發者ID:hamalawy,項目名稱:slmiv,代碼行數:21,代碼來源:SLMIVUtils.cs

示例4: writeBrainFile

 //write brain file to disc
 protected void writeBrainFile(StringCollection memoryBuffer)
 {
     if(fullPathName != "")
     {
         writeBrainFile(memoryBuffer, fullPathName);
         return;
     }
     File.Delete(filePath);
     FileStream fs = new FileStream(filePath , FileMode.OpenOrCreate, FileAccess.Write);
     StreamWriter sw = new StreamWriter(fs);
     sw.BaseStream.Seek(0, SeekOrigin.End);
     System.Collections.Specialized.StringEnumerator ii = memoryBuffer.GetEnumerator();
     while(ii.MoveNext())
     {
         string dat = ii.Current;
         sw.WriteLine(dat);
     }
     sw.Flush();
     sw.Close();
     fs.Close();
 }
開發者ID:sanyaade-g2g-repos,項目名稱:prelude-csharp,代碼行數:22,代碼來源:Brain.cs

示例5: MessageBoxIronPy

            /// <summary>
            /// Custom MessageBox call. Excepts some random objects from IronPython and converts to string.
            /// </summary>
            /// <param name="inobject">Output object from IronPython.</param>
            public static void MessageBoxIronPy(Object inobject)
            {
                Type itstype = inobject.GetType();

                switch (itstype.FullName)
                {
                    case "IronPython.Runtime.PythonDictionary":
                        //PythonDictionary IPDict = new PythonDictionary();
                       // IPDict = (PythonDictionary)inobject;
                       // MessageBox.Show(IPDict.ToString());
                        break;
                    case "IronPython.Runtime.List":
                       // List IPList = new List();
                      //  IPList = (List)inobject;
                       // MessageBox.Show(IPList.ToString());
                        break;
                    case "System.String":
                        MessageBox.Show(inobject.ToString());
                        break;
                    case "System.Int32":
                        MessageBox.Show(Convert.ToString(inobject));
                        break;
                    case "System.Collections.Specialized.StringCollection":
                        StringCollection IPSC = new StringCollection();
                        IPSC = (StringCollection)inobject;
                        StringEnumerator SCE = IPSC.GetEnumerator();
                        string output = "";
                        while (SCE.MoveNext())
                            output += SCE.Current.ToString();
                        MessageBox.Show(output);
                        break;
                    default:
                        MessageBox.Show(inobject.GetType().ToString() + " not yet implemented.");
                        break;
                }
            }
開發者ID:drzo,項目名稱:opensim4opencog,代碼行數:40,代碼來源:WinformREPLTextBox.cs

示例6: Convert_StringCollectiontoArrayList

        /// <summary>
        /// Returns aa ArrayList from a StringCollection  
        /// </summary>
        /// <param name="StringColin">Incoming StringCollection.</param>
        public ArrayList Convert_StringCollectiontoArrayList(StringCollection StringColin)
        {
            ArrayList newArrayList = new ArrayList();

            StringEnumerator myEnumerator = StringColin.GetEnumerator();
            while (myEnumerator.MoveNext())
                newArrayList.Add(myEnumerator.Current.ToString());

            return newArrayList;
        }
開發者ID:pterelaos,項目名稱:revitpythonshell,代碼行數:14,代碼來源:IronTextBox.cs

示例7: GetStringCollectValue

        /// <summary>
        /// Returns a string retrieved from a StringCollection.
        /// </summary>
        /// <param name="inCol">StringCollection to be searched.</param>
        /// <param name="index">index of StringCollection to retrieve.</param>
        public string GetStringCollectValue(StringCollection inCol, int index)
        {
            string value = "";
            int count = 0;
            var myEnumerator = inCol.GetEnumerator();
            while (myEnumerator.MoveNext())
            {
                if (index == count)
                {
                    value = myEnumerator.Current;
                }

                count = count + 1;
            }

            return value;
        }
開發者ID:pterelaos,項目名稱:revitpythonshell,代碼行數:22,代碼來源:IronTextBox.cs

示例8: Test01

        public void Test01()
        {
            StringCollection sc;
            StringEnumerator en;

            string curr;        // Eumerator.Current value

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

            // [] StringCollection GetEnumerator()
            //-----------------------------------------------------------------

            sc = new StringCollection();

            // [] Enumerator for empty collection
            //
            en = sc.GetEnumerator();
            string type = en.GetType().ToString();
            if (type.IndexOf("StringEnumerator", 0) == 0)
            {
                Assert.False(true, string.Format("Error, type is not StringEnumerator"));
            }

            //
            //  MoveNext should return false
            //
            bool res = en.MoveNext();
            if (res)
            {
                Assert.False(true, string.Format("Error, MoveNext returned true"));
            }

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

            //
            //   Filled collection
            // [] Enumerator for filled collection
            //
            sc.AddRange(values);

            en = sc.GetEnumerator();
            type = en.GetType().ToString();
            if (type.IndexOf("StringEnumerator", 0) == 0)
            {
                Assert.False(true, string.Format("Error, type is not StringEnumerator"));
            }

            //
            //  MoveNext should return true
            //

            for (int i = 0; i < sc.Count; i++)
            {
                res = en.MoveNext();
                if (!res)
                {
                    Assert.False(true, string.Format("Error, MoveNext returned false", i));
                }

                curr = en.Current;
                if (String.Compare(curr, sc[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, Current returned \"{1}\" instead of \"{2}\"", i, curr, sc[i]));
                }
                // while we didn't MoveNext, Current should return the same value
                string curr1 = en.Current;
                if (String.Compare(curr, curr1) != 0)
                {
                    Assert.False(true, string.Format("Error, second call of Current returned different result", i));
                }
            }

            // next MoveNext should bring us outside of the collection
            //
            res = en.MoveNext();
            res = en.MoveNext();
            if (res)
            {
                Assert.False(true, string.Format("Error, MoveNext returned true"));
            }

            //
            //  Attempt to get Current should result in exception
//.........這裏部分代碼省略.........
開發者ID:gitter-badger,項目名稱:corefx,代碼行數:101,代碼來源:GetEnumeratorTests.cs

示例9: ExtractParameters

    /// <summary>
    /// Extract flags, named and numbered parameters from a string array of arguments
    /// </summary>
    /// <param name="named">The found named parameters</param>
    /// <param name="numbered">The found numbered parameters</param>
    /// <param name="input">The arguments</param>
    /// <param name="flags">Allowed flags to find</param>
    public static void ExtractParameters(out StringDictionary named, out string[] numbered, string[] input, string[] flags)
    {
      named = new StringDictionary();
      StringCollection numberedColl = new StringCollection();
      StringCollection args = new StringCollection();
      args.AddRange(input);

      // Pull out flags first
      if (flags != null)
      {
        for (int i = 0; i < flags.Length; i++)
        {
          int ind = -1;
          if ((ind = args.IndexOf("-" + flags[i])) >= 0)
          {
            named.Add(flags[i], string.Empty);
            //	args.RemoveAt(ind);
            args[ind] = null;
          }
        }
      }

      // pull out named parameters
      StringEnumerator e = args.GetEnumerator();
      string name = string.Empty;
      while (e.MoveNext())
      {
        if (e.Current != null)
        {
          if (name != string.Empty)
          {
            string nextname = string.Empty;
            string value = e.Current;
            if (value == null)
              value = string.Empty;

            if (value.StartsWith("-") && value.Length > 1)
            {
              nextname = value.Substring(1);
              value = string.Empty;
            }

            if (value.StartsWith("\\-"))
              value = "-" + value.Substring(2);

            named.Add(name, value);

            if (nextname != string.Empty)
              name = nextname;
            else
              name = string.Empty;
          }
          else if (e.Current.StartsWith("-") && e.Current.Length > 1)
            name = e.Current.Substring(1);
          else
          {
            string value = e.Current;
            if (value.StartsWith("\\-"))
              value = "-" + value.Substring(2);

            numberedColl.Add(value);
          }
        }
        else
        {
          if (name != string.Empty)
          {
            named.Add(name, string.Empty);
            name = string.Empty;
          }
        }
      }

      if (name != string.Empty)
        named.Add(name, string.Empty);

      // Pull out numbered parameters
      numbered = new string[numberedColl.Count];
      numberedColl.CopyTo(numbered, 0);
    }
開發者ID:KerwinMa,項目名稱:revolver,代碼行數:87,代碼來源:ParameterUtil.cs

示例10: FindUser

 private bool FindUser(StringCollection users, string principal)
 {
     using (StringEnumerator enumerator = users.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             if (string.Equals(enumerator.Current, principal, StringComparison.OrdinalIgnoreCase))
             {
                 return true;
             }
         }
     }
     return false;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:14,代碼來源:AuthorizationRule.cs

示例11: ProcessRemoteUrls

 private void ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
 {
     StringEnumerator enumerator = urls.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string current = enumerator.Current;
         try
         {
             DiscoveryDocument document = client.DiscoverAny(current);
             client.ResolveAll();
             continue;
         }
         catch (Exception exception)
         {
             throw new InvalidOperationException("General Error " + current, exception);
         }
     }
     IDictionaryEnumerator enumerator2 = client.Documents.GetEnumerator();
     while (enumerator2.MoveNext())
     {
         DictionaryEntry entry = (DictionaryEntry)enumerator2.Current;
         this.AddDocument((string)entry.Key, entry.Value, schemas, descriptions);
     }
 }
開發者ID:hdougie,項目名稱:webservicestudio2,代碼行數:24,代碼來源:Wsdl.cs

示例12: ProcessLocalPaths

 private void ProcessLocalPaths(DiscoveryClientProtocol client, StringCollection localPaths, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
 {
     StringEnumerator enumerator = localPaths.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string current = enumerator.Current;
         string extension = Path.GetExtension(current);
         if (string.Compare(extension, ".discomap", true) == 0)
         {
             client.ReadAll(current);
         }
         else
         {
             object document = null;
             if (string.Compare(extension, ".wsdl", true) == 0)
             {
                 document = this.ReadLocalDocument(false, current);
             }
             else
             {
                 if (string.Compare(extension, ".xsd", true) != 0)
                 {
                     throw new InvalidOperationException("Unknown file type " + current);
                 }
                 document = this.ReadLocalDocument(true, current);
             }
             if (document != null)
             {
                 this.AddDocument(current, document, schemas, descriptions);
             }
         }
     }
 }
開發者ID:hdougie,項目名稱:webservicestudio2,代碼行數:33,代碼來源:Wsdl.cs

示例13: AppendSwitchFileCollection

		private void AppendSwitchFileCollection(StringWriter writer, string name, StringCollection collection)
		{
			if (collection != null)
			{
				StringEnumerator enumerator = collection.GetEnumerator();
				while (enumerator.MoveNext())
				{
					string item = enumerator.Current;
					AppendSwitchFileIfNotNull(writer, name, item);
				}
			}
		}
開發者ID:Orvid,項目名稱:NAntUniversalTasks,代碼行數:12,代碼來源:BabelTask.cs

示例14: SvnLookOutputParser

        private SvnLookOutputParser(StringCollection infoLines, StringCollection changedLines, StringCollection diffLines)
        {
            StringEnumerator strings = infoLines.GetEnumerator();
            strings.MoveNext();  // move to first
            strings.MoveNext();  // skip first
            FindAuthor(strings);
            FindTimestamp(strings);
            FindLogMessageSize(strings);
            FindLogMessage(strings);

            strings = changedLines.GetEnumerator();
            bool hasMoreLines = SkipBlanks(strings);
            if (!hasMoreLines)
                throw new ArgumentException("Unexpected: no changes recorded, aborting fatally");

            FindChanges(strings);

            if(diffLines != null && diffLines.Count > 0)
            {
                strings = diffLines.GetEnumerator();
                hasMoreLines = SkipBlanks(strings);

                if (hasMoreLines)
                    FillDiffCollection(strings);
            }
        }
開發者ID:AlexZeitler,項目名稱:SharpDevelop-Servers,代碼行數:26,代碼來源:SvnLookOutputParser.cs

示例15: ConvertToOD

        /// <summary>
        /// Appends a .inv formatted StringCollection to the OrderedDictionary OD_MyInventory
        /// </summary>
        /// <param name="SC_inv">.inv formatted StringCollection</param>
        public static void ConvertToOD(StringCollection SC_inv)
        {
            //Reset the OD_MyInventory
            OD_MyInventory.Clear();
            int icount = 0;

            // Enumerates the elements in the StringCollection.
            StringEnumerator myEnumerator = SC_inv.GetEnumerator();
            while (myEnumerator.MoveNext())
            {
                if (myEnumerator.Current != "")
                {
                    if (GetInvType(myEnumerator.Current) == INV_TYPE.FOLDER)
                    {
                        ///Folder tempf = Folder.Create(myEnumerator.Current);
                        ///Convert to Folder and assign in MD
                        ///OD_MyInventory.Add(tempf.cat_id, Folder.Create(myEnumerator.Current));
                        OD_MyInventory.Add(icount, Folder.Create(myEnumerator.Current));
                    }
                    else if (GetInvType(myEnumerator.Current) == INV_TYPE.ITEM)
                    {
                        ///Item tempi = Item.Create(myEnumerator.Current);
                        if (icount == 16)
                            icount = icount + 0;
                        OD_MyInventory.Add(icount, Item.Create(myEnumerator.Current));
                    }
                    else
                    {
                        MessageBox.Show("ConvertToOD exception: " + myEnumerator.Current + " is INV_TYPE.NULL");
                    }
                }
                icount = icount + 1;
            }
        }
開發者ID:hamalawy,項目名稱:slmiv,代碼行數:38,代碼來源:SLMIVUtils.cs


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