Esempio n. 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();
                }
            }
        }
Esempio n. 2
0
 public IDependencyScope BeginScope()
 {
     return(new CormoDependencyResolver(_componentManager, _creationalContext.GetCreationalContext(null)));
 }