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


C# ITreeNode.GetParentExpression方法代码示例

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


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

示例1: GetComponentRegistrations

        public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
        {
            var parentExpression = registrationRootElement.GetParentExpression<IExpressionStatement>();
            if (parentExpression == null)
            {
                yield break;
            }

            IStructuralMatchResult match = Match(registrationRootElement);

            if (match.Matched)
            {
                var expression = match.GetMatchedElement<ICSharpExpression>("expression");

                if (IsResolvedToObject(expression))
                {
                    yield break;
                }

                IEnumerable<IComponentRegistration> componentRegistrations = GetRegistrationsFromExpression(registrationRootElement, expression);

                IEnumerable<FilteredRegistrationBase> basedOnRegistrations = basedOnPatterns.SelectMany(
                   basedOnPattern => basedOnPattern.GetBasedOnRegistrations(parentExpression.Expression)).ToList();

                var registrations = componentRegistrations.Concat(basedOnRegistrations).ToList();

                if (registrations.Any())
                {
                    yield return new CompositeRegistration(registrationRootElement, registrations);
                }
            }
        }
开发者ID:hmemcpy,项目名称:AgentMulder,代码行数:32,代码来源:RegisterLambdaExpression.cs

示例2: GetComponentRegistrations

        public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
        {
            // This entire thing is one big hack. Need to come back to it one day :)
            // There is (currently) no way to create a pattern that would match the Bind() call with implicit 'this' in ReSharper SSR.
            // Therefore I'm only matching by the method name only, and later verifying that the method indeed belongs to Ninject, by
            // making sure the invocation's qualifier derived from global::Ninject.Syntax.IBindingRoot

            if (!registrationRootElement.IsContainerCall(NinjectBindingRootClrTypeName))
            {
                yield break;
            }

            var statement = registrationRootElement.GetParentExpression<IExpressionStatement>();
            if (statement == null)
            {
                yield break;
            }

            foreach (var toPattern in toPatterns)
            {
                var implementedByRegistration = toPattern.GetComponentRegistrations(statement.Expression)
                    .Cast<ComponentRegistration>()
                    .FirstOrDefault();

                if (implementedByRegistration != null)
                {
                    foreach (var registration in DoCreateRegistrations(statement.Expression).OfType<ComponentRegistration>())
                    {
                        registration.Implementation = implementedByRegistration.ServiceType;
                        yield return registration;
                    }
                }
            }
        }
开发者ID:hmemcpy,项目名称:AgentMulder,代码行数:34,代码来源:BindBasePattern.cs

示例3: GetComponentRegistrations

        public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
        {
            var parentExpression = registrationRootElement.GetParentExpression<IExpressionStatement>();
            if (parentExpression == null)
            {
                yield break;
            }

            IStructuralMatchResult match = Match(registrationRootElement);

            if (match.Matched)
            {
                var statements = match.GetMatchedElementList("statements").Cast<ICSharpStatement>().ToList();
                var collectedTypes = statements.SelectMany(statement =>
                {
                    var returnTypeCollector = new ReturnTypeCollector(new UniversalContext(statement.GetPsiModule()));
                    statement.ProcessThisAndDescendants(returnTypeCollector);
                    return returnTypeCollector.CollectedTypes;
                });

                IEnumerable<FilteredRegistrationBase> basedOnRegistrations = basedOnPatterns.SelectMany(
                   basedOnPattern => basedOnPattern.GetBasedOnRegistrations(parentExpression.Expression)).ToList();

                foreach (var type in collectedTypes)
                {
                    var declaredType = type as IDeclaredType;
                    if (declaredType != null)
                    {
                        var typeElement = declaredType.GetTypeElement();
                        if (typeElement != null)
                        {
                            yield return new CompositeRegistration(registrationRootElement,
                                new[] { new ServiceRegistration(registrationRootElement, typeElement) }
                                .Concat(basedOnRegistrations));
                        }
                    }
                }
            }
        }
开发者ID:hmemcpy,项目名称:AgentMulder,代码行数:39,代码来源:RegisterLambdaStatements.cs


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