本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax.ChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ArgumentSyntax.ChildNodes方法的具体用法?C# ArgumentSyntax.ChildNodes怎么用?C# ArgumentSyntax.ChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax
的用法示例。
在下文中一共展示了ArgumentSyntax.ChildNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitArgument
public override SyntaxNode VisitArgument(ArgumentSyntax node)
{
SyntaxNode r_node = node;
var p2 = node.HasParent<ArgumentListSyntax, InvocationExpressionSyntax>();
if (p2 == null)
{
}
else
{
var s3 = p2.GetSymbol(SemanticModel);
if (s3 == null)
{
}
else
{
var pa1 = s3.Parameters.FirstOrDefault(r1 => r1.HasAttribute<ParamToWebAPIUrl>());
if (pa1 == null)
{ }
else
{
var p1 = node.Parent as ArgumentListSyntax;
var index = p1.Arguments.IndexOf(node);
var param = node.GetParam(s3, index);
if (param.HasAttribute<ParamToWebAPIUrl>())
{
var controllerName = "";
//Expression<Func<Controller, T>> f1
var api = (param.Type as INamedTypeSymbol).TypeArguments[0] as INamedTypeSymbol;
//Func<Controller, T>
api = api.TypeArguments[0] as INamedTypeSymbol;
if (api.BaseType.Name == "ApiController")
{
controllerName = api.Name.Replace("Controller", "");
}
var subInvocationExpressionSyntax =
node.ChildNodes().Take(1).OfType<SimpleLambdaExpressionSyntax>()
.SelectMany(r1 => r1.ChildNodes().Skip(1).OfType<InvocationExpressionSyntax>())
;
var subFuncSyn = subInvocationExpressionSyntax
.Select(r => new { Node = r, MethodSymbol = r.GetSymbol(SemanticModel) })
.Take(1)
.FirstOrDefault(r => r != null);
if (subFuncSyn == null || subFuncSyn.MethodSymbol == null)
{ }
else
{
var functionName = subInvocationExpressionSyntax
.SelectMany(r1 => r1.ChildNodes().Take(1).OfType<MemberAccessExpressionSyntax>())
.SelectMany(r1 => r1.ChildNodes().Skip(1).OfType<IdentifierNameSyntax>())
.Select(r => r.Identifier.Text)
.FirstOrDefault();
if (string.IsNullOrEmpty(controllerName) || string.IsNullOrEmpty(functionName))
{ }
else
{
var nameEqual = SyntaxFactory.NameEquals("url");
var url = SyntaxFactory.ParseExpression(string.Format("\"api/{0}/{1}\"", controllerName, functionName));
r_node = SyntaxFactory.Argument(url);
}
}
}
}
}
}
return r_node;
}