本文整理汇总了C#中InvocationExpressionSyntax.Last方法的典型用法代码示例。如果您正苦于以下问题:C# InvocationExpressionSyntax.Last方法的具体用法?C# InvocationExpressionSyntax.Last怎么用?C# InvocationExpressionSyntax.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InvocationExpressionSyntax
的用法示例。
在下文中一共展示了InvocationExpressionSyntax.Last方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateProperties
static CompleterResult GenerateProperties(SemanticModel model, INamedTypeSymbol type, InvocationExpressionSyntax[] chain)
{
var last = (MemberAccessExpressionSyntax)chain.Last().Expression;
var ownerTypeSyntax = ((GenericNameSyntax)last.Expression).TypeArgumentList.Arguments.Single();
var ownerType = model.GetTypeInfo(ownerTypeSyntax).Type;
if(ownerType != type)
return new CompleterError(ownerTypeSyntax, Messages.DependecyProperty_IncorrectOwnerType).YieldToImmutable();
var properties = chain
.Take(chain.Length - 1)
.Select(property => {
var memberAccess = (MemberAccessExpressionSyntax)property.Expression;
var methodName = memberAccess.Name.Identifier.ValueText;
if(!methodName.StartsWith("Register"))
return null;
var readOnly = methodName == "RegisterReadOnly" || methodName == "RegisterAttachedReadOnly";
var attached = methodName == "RegisterAttached" || methodName == "RegisterAttachedReadOnly";
var arguments = property.ArgumentList.Arguments;
var propertySignature = (memberAccess.Name as GenericNameSyntax)?.TypeArgumentList.Arguments.Select(x => x.ToString()).ToArray();
if(propertySignature == null) {
var defaultValueArgument = arguments[readOnly ? 3 : 2].Expression;
var defaultExpressionTypeInfo = model.GetTypeInfo(defaultValueArgument);
propertySignature = defaultExpressionTypeInfo.Type?.DisplayString(model, defaultValueArgument.GetLocation()).With(propertyType =>
!attached
? new string[] { propertyType }
: (arguments[0].Expression as ParenthesizedLambdaExpressionSyntax).With(x => new string[] { x.ParameterList.Parameters.Single().Type.ToString(), propertyType })
);
}
if(propertySignature == null) {
var span = memberAccess.Name.LineSpan();
return new CompleterError(memberAccess.SyntaxTree, Messages.DependecyProperty_PropertyTypeMissed, new FileLinePositionSpan(string.Empty, span.EndLinePosition, span.EndLinePosition));
}
var propertyName = GetPropertyName(arguments, attached, readOnly, memberAccess.Name.SyntaxTree);
return propertyName.Select(name => {
var overridedPropertyVisibility = GetOverridedPropertyVisibility(type, name);
return GenerateFields(name, readOnly, overridedPropertyVisibility == null) + (attached
? GenerateAttachedProperty(propertySignature[0], propertySignature[1], name, readOnly, overridedPropertyVisibility)
: GenerateProperty(propertySignature.Single(), name, readOnly, overridedPropertyVisibility));
});
})
.Where(x => x != null)
.Reverse()
.ToArray();
return properties
.AggregateEither(errors => errors.ToImmutableArray(), values => values.ConcatStringsWithNewLines());
}