Example #1
0
        private object GetReference(IInjectionPoint injectionPoint, IComponent component, ICreationalContext creationalContext, params Type[] proxyTypes)
        {
            var pushInjectionPoint = injectionPoint != null && injectionPoint.ComponentType != typeof(IInjectionPoint);

            try
            {
                if (pushInjectionPoint)
                {
                    _currentInjectionPoint.Push(injectionPoint);
                }


                if (proxyTypes.Any() && component.IsProxyRequired)
                {
                    foreach (var proxyType in proxyTypes)
                    {
                        InjectionValidator.ValidateProxiable(proxyType, injectionPoint);
                    }

                    return(CormoProxyGenerator.CreateProxy(proxyTypes,
                                                           () =>
                    {
                        try
                        {
                            if (pushInjectionPoint)
                            {
                                _currentInjectionPoint.Push(injectionPoint);
                            }
                            return GetReference(injectionPoint, component, creationalContext, new Type[0]);
                        }
                        finally
                        {
                            if (pushInjectionPoint)
                            {
                                _currentInjectionPoint.Pop();
                            }
                        }
                    }));
                }

                var context = creationalContext as IWeldCreationalContext;
                if (context != null)
                {
                    var incompleteInstance = context.GetIncompleteInstance(component);
                    if (incompleteInstance != null)
                    {
                        return(incompleteInstance);
                    }
                }
                creationalContext = creationalContext.GetCreationalContext(component);
                return(GetContext(component.Scope).Get(component, creationalContext));
            }
            finally
            {
                if (pushInjectionPoint)
                {
                    _currentInjectionPoint.Pop();
                }
            }
        }
Example #2
0
 public FieldInjectionPoint(IComponent declaringComponent, IAnnotatedField field) :
     this(declaringComponent, field.Field, field.Annotations)
 {
     InjectionValidator.Validate(field);
 }
Example #3
0
 public PropertyInjectionPoint(IComponent declaringComponent, PropertyInfo property, IBinderAttribute[] binders) :
     base(declaringComponent, property, property.PropertyType, binders)
 {
     InjectionValidator.Validate(property);
     _property = property;
 }
Example #4
0
 public FieldInjectionPoint(IComponent declaringComponent, FieldInfo field, IBinderAttribute[] binders) :
     base(declaringComponent, field, field.FieldType, binders)
 {
     InjectionValidator.Validate(field);
     _field = field;
 }
Example #5
0
 public PropertyInjectionPoint(IComponent declaringComponent, IAnnotatedProperty property) :
     this(declaringComponent, property.Property, property.Annotations)
 {
     InjectionValidator.Validate(property);
 }