本文整理汇总了C#中ITreeNode.IsContainerCall方法的典型用法代码示例。如果您正苦于以下问题:C# ITreeNode.IsContainerCall方法的具体用法?C# ITreeNode.IsContainerCall怎么用?C# ITreeNode.IsContainerCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITreeNode
的用法示例。
在下文中一共展示了ITreeNode.IsContainerCall方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
}
}
示例2: GetComponentRegistrations
public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
{
// todo this is duplicated, needs refactoring!
// 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 Scan() call with implicit 'this' in ReSharper SSR
// (i.e. a call to Scan being made withing a method, located in the Registry class)
// Therefore I'm only matching by the method name only, and later verifying that the method indeed belongs to StructureMap, by
// making sure the invocation's qualifier derived from global::StructureMap.Configuration.DSL.IRegistry
if (!registrationRootElement.IsContainerCall(Constants.StructureMapRegistryTypeName))
{
yield break;
}
IInvocationExpression invocationExpression = registrationRootElement.GetInvocationExpression();
if (invocationExpression == null)
{
yield break;
}
IStructuralMatchResult match = Match(invocationExpression);
if (match.Matched)
{
var invocationExpressions = match.GetMatchedElementList("statements")
.OfType<IExpressionStatement>()
.WhereNotNull()
.Select(statement => statement.Expression)
.OfType<IInvocationExpression>()
.ToList();
var registrations = (from expression in invocationExpressions
from basedOnPattern in basedOnPatterns
from registration in basedOnPattern.GetBasedOnRegistrations(expression)
select registration).ToList();
if (!registrations.Any())
{
yield break;
}
var moduleRegistrations = (from expression in invocationExpressions
from pattern in fromAssemblyPatterns
from registration in pattern.GetComponentRegistrations(expression)
select registration).ToList();
foreach (var moduleRegistration in moduleRegistrations)
{
yield return new CompositeRegistration(registrationRootElement, registrations.Union(new[]
{
moduleRegistration
}));
}
}
}
示例3: GetComponentRegistrations
public override IEnumerable<IComponentRegistration> GetComponentRegistrations(ITreeNode registrationRootElement)
{
// todo this is duplicated from Ninject!
// 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 For() call with implicit 'this' in ReSharper SSR
// (i.e. a call to Foo being made withing a method, located in the Registry class)
// Therefore I'm only matching by the method name only, and later verifying that the method indeed belongs to StructureMap, by
// making sure the invocation's qualifier derived from global::StructureMap.Configuration.DSL.IRegistry
if (!registrationRootElement.IsContainerCall(Constants.StructureMapRegistryTypeName))
{
yield break;
}
IInvocationExpression invocationExpression = registrationRootElement.GetInvocationExpression();
if (invocationExpression == null)
{
yield break;
}
foreach (var usePattern in usePatterns)
{
var implementedByRegistration = usePattern.GetComponentRegistrations(invocationExpression)
.Cast<ComponentRegistration>()
.FirstOrDefault();
if (implementedByRegistration != null)
{
foreach (var registration in DoCreateRegistrations(invocationExpression).OfType<ComponentRegistration>())
{
registration.Implementation = implementedByRegistration.ServiceType;
yield return registration;
}
}
}
}