当前位置: 首页>>代码示例>>C#>>正文


C# INamedTypeSymbol.GetValidAnonymousTypeProperties方法代码示例

本文整理汇总了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;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:30,代码来源:CSharpAnonymousTypeDisplayService.cs

示例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();
                }
            }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:35,代码来源:SymbolEquivalenceComparer.EquivalenceVisitor.cs

示例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


注:本文中的INamedTypeSymbol.GetValidAnonymousTypeProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。