本文整理汇总了C#中System.Collections.Specialized.StringCollection.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# StringCollection.Cast方法的具体用法?C# StringCollection.Cast怎么用?C# StringCollection.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.StringCollection
的用法示例。
在下文中一共展示了StringCollection.Cast方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StringCollection2List
public static void StringCollection2List()
{
StringCollection stringCollection = new StringCollection();
stringCollection.Add("String 1");
stringCollection.Add("String 2");
stringCollection.Add("String 3");
Console.WriteLine("*** StringCollection:");
foreach (String s in stringCollection)
{
Console.WriteLine(s);
}
List<String> stringList = stringCollection.Cast<String>().ToList();
Console.WriteLine("*** List<String>:");
foreach (String s in stringList)
{
Console.WriteLine(s);
}
}
示例2: StripElementAttributes
private void StripElementAttributes(params string[] attributeNames)
{
StringCollection selectors = new StringCollection();
foreach (string attribute in attributeNames)
{
selectors.Add(String.Format("*[{0}]", attribute));
}
CQ elementsWithAttributes = _document.Find(String.Join(",", selectors.Cast<string>().ToList()));
foreach (var item in elementsWithAttributes)
{
foreach (string attribute in attributeNames)
{
item.RemoveAttribute(attribute);
}
}
}
示例3: ParseWurflFiles
/// <summary>
/// Parses the wurfl file into a instance of WurflFile.
/// </summary>
/// <param name="devices">Instance of Devices to store data.</param>
/// <param name="wurflFilePath">Wurfl file path.</param>
/// <param name="capabilitiesWhiteList">List of capabilities to be used. If none, all capabilities will be loaded into the memory.</param>
/// <param name="wurflPatchFiles">Null, string or array of strings representing the wurfl patch files
/// which must be applied against the main file.</param>
/// <returns>Returns an instance of WurflFile.
/// <remarks>If none file is found a null value will be returned.</remarks>
/// </returns>
/// <exception cref="System.IO.FileNotFoundException">Thrown if the parameter <paramref name="wurflFilePath"/>
/// referes to a file that does not exists.</exception>
/// <exception cref="System.ArgumentNullException">Thrown if the parameter <paramref name="wurflFilePath"/>
/// is an empty string or a null value.</exception>
private static void ParseWurflFiles(
Provider devices,
string wurflFilePath,
StringCollection capabilitiesWhiteList,
params string[] wurflPatchFiles)
{
if (string.IsNullOrEmpty(wurflFilePath))
throw new ArgumentNullException("wurflFilePath");
if (!File.Exists(wurflFilePath))
throw new FileNotFoundException(Constants.WurflFileNotFound, wurflFilePath);
// Load white listed capabilities
if (capabilitiesWhiteList != null)
{
_loadOnlyCapabilitiesWhiteListed = capabilitiesWhiteList.Count > 0;
#if VER4
foreach (string capability in
capabilitiesWhiteList.Cast<string>().Where(capability => !_capabilitiesWhiteListed.Contains(capability)))
{
_capabilitiesWhiteListed.Add(capability);
}
#elif VER2
foreach (string capability in capabilitiesWhiteList)
if (!_capabilitiesWhiteListed.Contains(capability))
_capabilitiesWhiteListed.Add(capability);
#endif
}
StringCollection wurflFilePaths = new StringCollection();
wurflFilePaths.Add(wurflFilePath);
wurflFilePaths.AddRange(wurflPatchFiles);
ParseWurflFiles(devices, wurflFilePaths, File.GetCreationTimeUtc(wurflFilePath));
}
示例4: AddQuery
protected void AddQuery(string fieldName, BoolQuery<ESDocument> query, StringCollection filter)
{
fieldName = fieldName.ToLower();
if (filter.Count > 0)
{
if (filter.Count == 1)
{
if (!String.IsNullOrEmpty(filter[0]))
{
AddQuery(fieldName, query, filter[0].ToLower());
}
}
else
{
var booleanQuery = new BoolQuery<ESDocument>();
var containsFilter = false;
foreach (var index in filter.Cast<string>().Where(index => !String.IsNullOrEmpty(index)))
{
booleanQuery.Should(q => q.Custom("{{\"wildcard\" : {{ \"{0}\" : \"{1}\" }}}}", fieldName.ToLower(), index.ToLower()));
containsFilter = true;
}
if (containsFilter)
query.Must(q => q.Bool(b => booleanQuery));
}
}
}
示例5: FromCollection
public static string FromCollection(StringCollection collection)
{
return string.Join(Environment.NewLine, collection.Cast<string>().ToArray());
}
示例6: TransformScript
private static IEnumerable<string> TransformScript(StringCollection script)
{
Trace.WriteLine(script.Cast<string>().Aggregate((s1, s2) => s1 + Environment.NewLine + s2));
return script.Cast<string>()
.Where(c => !c.StartsWith("USE ", StringComparison.OrdinalIgnoreCase))
.Select(c =>
{
// some SMO statements are prefixed with a comment like: /**** bla bla ****/\r\n
string endOfComment = "*/" + Environment.NewLine;
int endOfCommentIndex = c.IndexOf(endOfComment, StringComparison.OrdinalIgnoreCase);
if (endOfCommentIndex > 0)
{
return c.Substring(endOfCommentIndex + endOfComment.Length);
}
return c;
});
}