本文整理汇总了C#中INamedTypeSymbol.GetValidAnonymousTypeProperties方法的典型用法代码示例。如果您正苦于以下问题:C# INamedTypeSymbol.GetValidAnonymousTypeProperties方法的具体用法?C# INamedTypeSymbol.GetValidAnonymousTypeProperties怎么用?C# INamedTypeSymbol.GetValidAnonymousTypeProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INamedTypeSymbol
的用法示例。
在下文中一共展示了INamedTypeSymbol.GetValidAnonymousTypeProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAnonymousTypeParts
public override IEnumerable<SymbolDisplayPart> GetAnonymousTypeParts(
INamedTypeSymbol anonymousType, SemanticModel semanticModel, int position, ISymbolDisplayService displayService)
{
var members = new List<SymbolDisplayPart>();
members.Add(Keyword(SyntaxFacts.GetText(SyntaxKind.NewKeyword)));
members.AddRange(Space());
members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.OpenBraceToken)));
members.AddRange(Space());
bool first = true;
foreach (var property in anonymousType.GetValidAnonymousTypeProperties())
{
if (!first)
{
members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.CommaToken)));
members.AddRange(Space());
}
first = false;
members.AddRange(displayService.ToMinimalDisplayParts(semanticModel, position, property.Type).Select(p => p.MassageErrorTypeNames("?")));
members.AddRange(Space());
members.Add(new SymbolDisplayPart(SymbolDisplayPartKind.PropertyName, property, property.Name));
}
members.AddRange(Space());
members.Add(Punctuation(SyntaxFacts.GetText(SyntaxKind.CloseBraceToken)));
return members;
}
示例2: HandleAnonymousTypes
private bool HandleAnonymousTypes(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol> equivalentTypesWithDifferingAssemblies)
{
if (x.TypeKind == TypeKind.Delegate)
{
return AreEquivalent(x.DelegateInvokeMethod, y.DelegateInvokeMethod, equivalentTypesWithDifferingAssemblies);
}
else
{
var xMembers = x.GetValidAnonymousTypeProperties();
var yMembers = y.GetValidAnonymousTypeProperties();
var xMembersEnumerator = xMembers.GetEnumerator();
var yMembersEnumerator = yMembers.GetEnumerator();
while (xMembersEnumerator.MoveNext())
{
if (!yMembersEnumerator.MoveNext())
{
return false;
}
var p1 = xMembersEnumerator.Current;
var p2 = yMembersEnumerator.Current;
if (p1.Name != p2.Name ||
p1.IsReadOnly != p2.IsReadOnly ||
!AreEquivalent(p1.Type, p2.Type, equivalentTypesWithDifferingAssemblies))
{
return false;
}
}
return !yMembersEnumerator.MoveNext();
}
}
示例3: VisitNamedType
public override void VisitNamedType(INamedTypeSymbol symbol)
{
if (_seenTypes.Add(symbol))
{
if (symbol.IsNormalAnonymousType())
{
_namedTypes.Add(symbol);
foreach (var property in symbol.GetValidAnonymousTypeProperties())
{
property.Accept(this);
}
}
else if (symbol.IsAnonymousDelegateType())
{
symbol.DelegateInvokeMethod.Accept(this);
}
else
{
foreach (var typeArgument in symbol.GetAllTypeArguments())
{
typeArgument.Accept(this);
}
}
}
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:26,代码来源:AbstractAnonymousTypeDisplayService.NormalAnonymousTypeCollectorVisitor.cs