Ejemplo n.º 1
0
        private AbstractComponent(Type type, IAnnotations annotations, WeldComponentManager manager)
        {
            Annotations = annotations;
            var qualifierSet = new HashSet <IQualifier>(Annotations.OfType <IQualifier>());

            if (qualifierSet.All(x => (x is AnyAttribute)))
            {
                qualifierSet.Add(DefaultAttribute.Instance);
            }

            Type                   = type;
            Manager                = manager;
            Scope                  = annotations.OfType <ScopeAttribute>().Select(x => x.GetType()).FirstOrDefault() ?? typeof(DependentAttribute);
            IsProxyRequired        = typeof(NormalScopeAttribute).IsAssignableFrom(Scope) && !Annotations.OfType <UnwrapAttribute>().Any();
            _lazyBuildPlan         = new Lazy <BuildPlan>(GetBuildPlan);
            IsConditionalOnMissing = Annotations.OfType <ConditionalOnMissingComponentAttribute>().Any();
        }
Ejemplo n.º 2
0
 protected AbstractInjectionPoint(IComponent declaringComponent, MemberInfo member, Type type, IAnnotations annotations)
 {
     DeclaringComponent = declaringComponent;
     Member             = member;
     ComponentType      = type;
     Annotations        = annotations;
     IsCacheable        = IsCacheableType(type);
     Unwraps            = annotations.OfType <UnwrapAttribute>().Any();
     _lazyComponents    = new Lazy <IComponent>(ResolveComponents);
     _lazyInjectPlan    = new Lazy <InjectPlan>(() => BuildInjectPlan(Component));
     _lazyGetValuePlan  = new Lazy <BuildPlan>(BuildGetValuePlan);
 }