本文整理汇总了C#中ITypeSymbol.GetBaseTypesAndThis方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeSymbol.GetBaseTypesAndThis方法的具体用法?C# ITypeSymbol.GetBaseTypesAndThis怎么用?C# ITypeSymbol.GetBaseTypesAndThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeSymbol
的用法示例。
在下文中一共展示了ITypeSymbol.GetBaseTypesAndThis方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMissingProperties
private static IEnumerable<IMethodSymbol> GetMissingProperties(InitializerExpressionSyntax expression, ITypeSymbol typeSymbol)
{
var properties =
typeSymbol.GetBaseTypesAndThis().SelectMany(x => x.GetMembers()).Where(x => x.Kind == SymbolKind.Method).Cast<IMethodSymbol>().Where(
x => x.MethodKind == MethodKind.PropertySet);
var missingprops = GetUnimplemntedProperties(expression, properties);
return missingprops;
}
示例2: ImplementsSomethingFor
private static bool ImplementsSomethingFor(ITypeSymbol type, IEnumerable<IMethodSymbol> missingprops)
{
return type.GetBaseTypesAndThis().SelectMany(x => x.GetMembers()).Where(x => x.Kind == SymbolKind.Property).Cast<IPropertySymbol>().Any(x => x.IsMissing(missingprops));
}
示例3: ImplementAllSettersFromExpression
private static SyntaxNode ImplementAllSettersFromExpression(InitializerExpressionSyntax expression,
string sourcename,
ITypeSymbol targetTypeInfo,
ITypeSymbol sourceType)
{
var missingprops = GetMissingProperties(expression, targetTypeInfo);
var newproperties =
sourceType.GetBaseTypesAndThis().SelectMany(x => x.GetMembers()).Where(x => x.Kind == SymbolKind.Property).Cast<IPropertySymbol>().Where(x => x.IsMissing(missingprops));
var newExpression = expression.AddExpressions(
newproperties.Select(x =>
SyntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression,
SyntaxFactory.IdentifierName(x.Name),
SyntaxFactory.MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
SyntaxFactory.IdentifierName(sourcename),
SyntaxFactory.IdentifierName(x.Name))))
.Cast<ExpressionSyntax>().ToArray());
return newExpression;
}