public static IAutowireContext GetAutowireContext(this Node node) { var current = node; while (current != null) { var target = current.FindDelegate().IfNone(current); var type = target.GetType(); var attribute = AttributeCache.GetOrCreate( type, _ => type.GetCustomAttribute <AutowireContextAttribute>(true)); if (attribute != null) { return(AutowireContext.GetOrCreate(target)); } current = current.GetParent(); } return(GetRootContext(node)); }
public static IAutowireContext GetAutowireContext([NotNull] this Node node) { Ensure.Any.IsNotNull(node, nameof(node)); var current = node; while (current != null) { var type = current.GetType(); var attribute = AttributeCache.GetOrCreate( type, _ => type.GetCustomAttribute <AutowireContextAttribute>(true)); if (attribute != null) { return(AutowireContext.GetOrCreate(current)); } current = current.GetParent(); } return(GetRootContext(node)); }
public static IAutowireContext GetRootContext([NotNull] this Node node) => AutowireContext.GetOrCreate(node.GetTree().Root);
public static IAutowireContext GetRootContext(this Node node) { Ensure.That(node, nameof(node)).IsNotNull(); return(AutowireContext.GetOrCreate(node.GetTree().Root)); }