本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxList.ToList方法的具体用法?C# SyntaxList.ToList怎么用?C# SyntaxList.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList
的用法示例。
在下文中一共展示了SyntaxList.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _GetUsing
// what was Syntax once is now SyntaxFactory
/// <summary>
/// Figures the usings and inserts them in the syntax tree.
/// </summary>
/// <param name="presentUsings">The usings already found in the source (have to be valid C#).</param>
/// <param name="optionalUsingsToAdd">All usings that need to be added.</param>
private static void _GetUsing(SyntaxList<UsingDirectiveSyntax> presentUsings, List<string> optionalUsingsToAdd = null)
{
var tmp = presentUsings.ToList();
var tmpList = new List<string>();
if (optionalUsingsToAdd != null && optionalUsingsToAdd.Any())
{
foreach (var item in optionalUsingsToAdd)
{
foreach (var syntax in tmp)
{
if (syntax.Name.GetText().ToString() == item)
{
tmpList.Add(item);
}
}
}
foreach (var item in tmpList)
{
tmp.RemoveAll(x => x.Name.GetText().ToString() == item);
}
}
foreach (var usn in optionalUsingsToAdd)
{
NameSyntax name = SyntaxFactory.IdentifierName(usn);
// to do: modify the tree and add the new usings
}
}