本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
}
示例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;
}
示例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;
}
示例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
//.........这里部分代码省略.........
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
}