本文整理汇总了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);
}
}
}
示例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;
}
}
}
}
示例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));
}
}
}
}
}