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


C# Binder.WithAdditionalFlags方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Binder.WithAdditionalFlags方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.WithAdditionalFlags方法的具体用法?C# Binder.WithAdditionalFlags怎么用?C# Binder.WithAdditionalFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.CSharp.Binder的用法示例。


在下文中一共展示了Binder.WithAdditionalFlags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MemberSemanticModel

        protected MemberSemanticModel(CSharpCompilation compilation, CSharpSyntaxNode root, Symbol memberSymbol, Binder rootBinder, SyntaxTreeSemanticModel parentSemanticModelOpt, int speculatedPosition)
        {
            Debug.Assert(compilation != null);
            Debug.Assert(root != null);
            Debug.Assert((object)memberSymbol != null);
            Debug.Assert(parentSemanticModelOpt == null || !parentSemanticModelOpt.IsSpeculativeSemanticModel, CSharpResources.ChainingSpeculativeModelIsNotSupported);

            this.compilation = compilation;
            this.root = root;
            this.memberSymbol = memberSymbol;
            this.RootBinder = rootBinder.WithAdditionalFlags(BinderFlags.SemanticModel);
            this.parentSemanticModelOpt = parentSemanticModelOpt;
            this.speculatedPosition = speculatedPosition;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:14,代码来源:MemberSemanticModel.cs

示例2: GetReducedAndFilteredMethodGroupSymbols

        internal static ImmutableArray<MethodSymbol> GetReducedAndFilteredMethodGroupSymbols(Binder binder, BoundMethodGroup node)
        {
            var methods = ArrayBuilder<MethodSymbol>.GetInstance();
            var filteredMethods = ArrayBuilder<MethodSymbol>.GetInstance();
            var resultKind = LookupResultKind.Empty;
            var typeArguments = node.TypeArgumentsOpt;

            // Non-extension methods.
            if (node.Methods.Any())
            {
                // This is the only place we care about overridden/hidden methods.  If there aren't methods
                // in the method group, there's only one fallback candidate and extension methods never override
                // or hide instance methods or other extension methods.
                ImmutableArray<MethodSymbol> nonHiddenMethods = FilterOverriddenOrHiddenMethods(node.Methods);
                Debug.Assert(nonHiddenMethods.Any()); // Something must be hiding, so can't all be hidden.

                foreach (var method in nonHiddenMethods)
                {
                    MergeReducedAndFilteredMethodGroupSymbol(
                        methods,
                        filteredMethods,
                        new SingleLookupResult(node.ResultKind, method, node.LookupError),
                        typeArguments,
                        null,
                        ref resultKind);
                }
            }
            else
            {
                var otherSymbol = node.LookupSymbolOpt;
                if (((object)otherSymbol != null) && (otherSymbol.Kind == SymbolKind.Method))
                {
                    MergeReducedAndFilteredMethodGroupSymbol(
                        methods,
                        filteredMethods,
                        new SingleLookupResult(node.ResultKind, otherSymbol, node.LookupError),
                        typeArguments,
                        null,
                        ref resultKind);
                }
            }

            var receiver = node.ReceiverOpt;
            var name = node.Name;

            // Extension methods, all scopes.
            if (node.SearchExtensionMethods)
            {
                Debug.Assert(receiver != null);
                int arity;
                LookupOptions options;
                if (typeArguments.IsDefault)
                {
                    arity = 0;
                    options = LookupOptions.AllMethodsOnArityZero;
                }
                else
                {
                    arity = typeArguments.Length;
                    options = LookupOptions.Default;
                }

                binder = binder.WithAdditionalFlags(BinderFlags.SemanticModel);
                foreach (var scope in new ExtensionMethodScopes(binder))
                {
                    var extensionMethods = ArrayBuilder<MethodSymbol>.GetInstance();
                    var otherBinder = scope.Binder;
                    otherBinder.GetCandidateExtensionMethods(scope.SearchUsingsNotNamespace,
                                                             extensionMethods,
                                                             name,
                                                             arity,
                                                             options,
                                                             originalBinder: binder);

                    foreach (var method in extensionMethods)
                    {
                        HashSet<DiagnosticInfo> useSiteDiagnostics = null;
                        MergeReducedAndFilteredMethodGroupSymbol(
                            methods,
                            filteredMethods,
                            binder.CheckViability(method, arity, options, accessThroughType: null, diagnose: false, useSiteDiagnostics: ref useSiteDiagnostics),
                            typeArguments,
                            receiver.Type,
                            ref resultKind);
                    }

                    extensionMethods.Free();
                }
            }

            methods.Free();
            return filteredMethods.ToImmutableAndFree();
        }
开发者ID:,项目名称:,代码行数:93,代码来源:


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