public EventComponent(Type eventType, Annotations annotations, WeldComponentManager manager) : base("", typeof(Events <>).MakeGenericType(eventType), annotations, manager) { _eventType = eventType; _annotations = annotations; _lazyEventObserverMethods = new Lazy <EventObserverMethod[]>(ResolveObserverMethods); }
public InterceptorMethodHandler(WeldComponentManager manager, MethodInfo method, Interceptor[] interceptors, ICreationalContext creationalContext) { _interceptorReferences = new LinkedList <IAroundInvokeInterceptor>( interceptors.Select(x => manager.GetReference(x, creationalContext)) .Cast <IAroundInvokeInterceptor>()); _bindingsLazy = new Lazy <IEnumerable <IInterceptorBinding> >(() => method.GetAnnotations().OfType <IInterceptorBinding>().ToArray()); var returnType = method.ReturnType; if (returnType == typeof(Task)) { _isAsync = true; _taskCaster = TaskCasters.ForVoid(); } else if (returnType.IsGenericType) { var genericType = returnType.GetGenericTypeDefinition(); if (genericType == typeof(Task <>)) { _isAsync = true; _taskCaster = TaskCasters.ForType(returnType.GetGenericArguments()[0]); } } }
public Instance(WeldComponentManager manager, IQualifier[] qualifiers, IWeldComponent[] components, ICreationalContext creationalContext) { _qualifiers = qualifiers; _components = components; _creationalContext = creationalContext; _currentInjectionPoint = manager.GetService <CurrentInjectionPoint>(); _injectionPoint = _currentInjectionPoint.Peek(); }
public ExtensionComponent(Type type, WeldComponentManager manager) : base(type.FullName, type, Weld.Annotations.Empty, manager) { try { _instance = (IExtension)Activator.CreateInstance(type); } catch (Exception e) { throw new CreationException(type, e); } }
public Interceptor(IAnnotatedType type, WeldComponentManager manager, bool allowPartialInterception) : base(type, manager) { AllowPartialInterception = allowPartialInterception; InterceptorBindings = Annotations.OfType <IInterceptorBinding>().Select(x => x.GetType()).ToArray(); InterceptorTypes = AllInterceptorTypes.Where(x => x.IsAssignableFrom(type.Type)).ToArray(); if (!InterceptorBindings.Any()) { throw new InvalidComponentException(type.Type, "Interceptor must have at least one interceptor-binding attribute"); } if (!InterceptorTypes.Any()) { throw new InvalidComponentException(type.Type, "Interceptor must implement " + string.Join(" or ", AllInterceptorTypes.Select(x => x.ToString()))); } }
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(); }
private AbstractComponent(Type type, IEnumerable <IBinderAttribute> binders, Type scope, WeldComponentManager manager) { var qualifierSet = new HashSet <IQualifier>(binders.OfType <IQualifier>()); if (qualifierSet.All(x => (x is AnyAttribute))) { qualifierSet.Add(DefaultAttribute.Instance); } Type = type; Manager = manager; Binders = binders; Qualifiers = qualifierSet; Scope = scope; IsProxyRequired = typeof(NormalScopeAttribute).IsAssignableFrom(scope); _lazyBuildPlan = new Lazy <BuildPlan>(GetBuildPlan); IsConditionalOnMissing = binders.OfType <ConditionalOnMissingComponentAttribute>().Any(); }
protected ManagedComponent(IAnnotatedType type, WeldComponentManager manager) : base(type.Type.FullName, type.Type, type.Annotations, manager) { _isConcrete = !Type.ContainsGenericParameters; if (_isConcrete) { var methods = type.Methods.ToArray(); var iMethods = methods.Where(InjectionValidator.ScanPredicate).ToArray(); var iProperties = type.Properties.Where(InjectionValidator.ScanPredicate).ToArray(); var iCtors = type.Constructors.Where(InjectionValidator.ScanPredicate).ToArray(); var iFields = type.Fields.Where(InjectionValidator.ScanPredicate).ToArray(); var postConstructs = methods.Where(x => x.Annotations.OfType <PostConstructAttribute>().Any()).Select(x => x.Method).ToArray(); if (iCtors.Length > 1) { throw new InvalidComponentException(type.Type, "Multiple [Inject] constructors"); } var iCtor = iCtors.FirstOrDefault() ?? type.Constructors.First(x => !x.Parameters.Any()); _injectableConstructor = new InjectableConstructor(this, iCtor.Constructor); var methodInjects = iMethods.Select(m => new InjectableMethod(this, m.Method, null)).ToArray(); var fieldInjects = iFields.Select(f => new FieldInjectionPoint(this, f)).ToArray(); var propertyInjects = iProperties.Select(p => new PropertyInjectionPoint(this, p)).ToArray(); AddMemberInjectionPoints(fieldInjects.Cast <IWeldInjetionPoint>().Union(propertyInjects).ToArray()); AddInjectableMethods(methodInjects); PostConstructs = postConstructs; ValidateMethodSignatures(); IsDisposable = typeof(IDisposable).IsAssignableFrom(Type); } }
public ProducerProperty(IWeldComponent component, PropertyInfo property, IAnnotations annotations, WeldComponentManager manager) : base(component, property, property.PropertyType, annotations, manager) { _property = property; }
public ProducerField(IWeldComponent component, IAnnotatedField field, WeldComponentManager manager) : this(component, field.Field, field.Annotations, manager) { }
private ProducerField(IWeldComponent component, FieldInfo field, IAnnotations annotations, WeldComponentManager manager) : base(component, field, field.FieldType, annotations, manager) { _field = field; }
private CormoApplication() { Environment = new WeldEnvironment(); Manager = new WeldComponentManager("deployment"); Deployer = new AttributeScanDeployer(Manager, Environment); }
public ValueComponent(object instance, IEnumerable <IQualifier> qualifiers, Type scope, WeldComponentManager manager) : base(instance.GetType().FullName, instance.GetType(), qualifiers, scope, manager) { _instance = instance; }
private ClassComponent(ClassComponent parent, Type type, IEnumerable <IBinderAttribute> binders, Type scope, WeldComponentManager manager, GenericUtils.Resolution typeResolution) : base(new ComponentIdentifier(parent.Id.Key, type), type, binders, scope, manager, parent.PostConstructs.Select(x => GenericUtils.TranslateMethodGenericArguments(x, typeResolution.GenericParameterTranslations)).ToArray()) { parent.TransferInjectionPointsTo(this, typeResolution); _lazyMixins = new Lazy <Mixin[]>(() => Manager.GetMixins(this)); _lazyInterceptors = new Lazy <Interceptor[]>(() => new Interceptor[0]); //_lazyInterceptors = new Lazy<Interceptor[]>(() => Manager.GetInterceptors(this)); //_interceptedMethods = InitInterceptedMethods(); }
protected AbstractComponent(string idSuffix, Type type, IAnnotations annotations, WeldComponentManager manager) : this(type, annotations, manager) { _id = new ComponentIdentifier(string.Format("{0}-{1}-{2}", manager.Id, GetType().Name, idSuffix)); }
public void Setup() { _manager = new WeldComponentManager("test"); _deployer = new AttributeScanDeployer(_manager, new WeldEnvironment()); }
public ExceptionHandlerDispatcher(WeldComponentManager manager, IEnumerable <EventObserverMethod> handlers) { _handlerResolver = new ObserverResolver(manager, handlers.ToArray()); }
public InstanceComponent(Type baseType, IAnnotations annotations, WeldComponentManager manager, IWeldComponent[] components) : base("", typeof(Instance <>).MakeGenericType(baseType), annotations, manager) { _baseType = baseType; _components = components; }
public ValueComponent(object instance, WeldComponentManager manager) : base(instance.GetType().FullName, instance.GetType(), Weld.Annotations.Empty, manager) { _instance = instance; }
public ProducerProperty(IWeldComponent component, PropertyInfo property, IEnumerable <IBinderAttribute> binders, Type scope, WeldComponentManager manager) : base(component, property, property.PropertyType, binders, scope, manager) { _property = property; }
public MixinResolver(WeldComponentManager manager, IEnumerable <Mixin> allComponents) : base(manager, allComponents) { }
//private ClassComponent(ClassComponent parent, ConstructorInfo ctor, IAnnotations Annotations, Type scope, WeldComponentManager manager, GenericResolver.Resolution typeResolution) // : base(new ComponentIdentifier(parent.Id.Key, ctor.DeclaringType), ctor, Annotations, scope, manager, // parent.PostConstructs.Select(x => GenericUtils.TranslateMethodGenericArguments(x, typeResolution.GenericParameterTranslations)).ToArray()) //{ // parent.TransferInjectionPointsTo(this, typeResolution); //} public ClassComponent(IAnnotatedType type, WeldComponentManager manager) : base(type, manager) { AnnotatedType = type; }
public InterceptorResolver(WeldComponentManager manager, IEnumerable <Interceptor> allComponents) : base(manager, allComponents) { }
protected ContextualResolver(WeldComponentManager manager, IEnumerable <TComponent> allComponents) : base(manager, allComponents) { }
public void Initialize(WeldComponentManager componentManager) { _componentManager = componentManager; }
protected TypeSafeResolver(WeldComponentManager manager, IEnumerable <TComponent> allComponents) { Manager = manager; _registeredComponents = allComponents; _allComponents = new ConcurrentBag <TComponent>(_registeredComponents); }
public ClassComponent(Type type, IEnumerable <IBinderAttribute> binders, Type scope, WeldComponentManager manager, MethodInfo[] postConstructs) : base(type, binders, scope, manager, postConstructs) { _lazyMixins = new Lazy <Mixin[]>(() => Manager.GetMixins(this)); _lazyInterceptors = new Lazy <Interceptor[]>(() => new Interceptor[0]); }
protected AbstractComponent(ComponentIdentifier id, Type type, IAnnotations annotations, WeldComponentManager manager) : this(type, annotations, manager) { _id = id; }
protected AbstractProducer(IWeldComponent declaringComponent, MemberInfo member, Type returnType, IAnnotations annotations, WeldComponentManager manager) : base(Formatters.Member(member), returnType, annotations, manager) { _containsGenericParameters = GenericUtils.MemberContainsGenericArguments(member); DeclaringComponent = declaringComponent; }
public ProducerMethod(IWeldComponent declaringComponent, MethodInfo method, IEnumerable <IBinderAttribute> binders, Type scope, WeldComponentManager manager) : base(declaringComponent, method, method.ReturnType, binders, scope, manager) { _method = method; }