예제 #1
0
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            var output = ProxiedResolver.Resolve(request);

            if (output.IsSuccess)
            {
                return(output);
            }

            return(fallbackResolver.Resolve(request));
        }
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            var registration = GetRegistration(request);

            if (registration != null)
            {
                circularDependencyDetector.ThrowOnCircularDependency(registration, request.ResolutionPath);
            }

            return(ProxiedResolver.Resolve(request));
        }
예제 #3
0
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            var result = ProxiedResolver.Resolve(request);

            if (result.IsSuccess)
            {
                return(result);
            }

            var defaultValue = GetDefaultForType(request.ServiceType);

            return(ResolutionResult.Success(request.ResolutionPath, defaultValue));
        }
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (!IsRequestForNamedInstanceDictionary(request))
            {
                return(ProxiedResolver.Resolve(request));
            }

            return(ResolveNamedInstanceDictionary(request));
        }
예제 #5
0
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            if (!lazyFactory.IsLazyType(request.ServiceType))
            {
                return(ProxiedResolver.Resolve(request));
            }

            var lazyInnerType = lazyFactory.GetInnerLazyType(request.ServiceType);
            var lazyRequest   = GetLazyResolutionRequest(request, lazyInnerType);

            var lazyObject = lazyFactory.GetLazyObject(lazyInnerType, GetObjectFactory(lazyRequest));

            return(ResolutionResult.Success(request.ResolutionPath, lazyObject));
        }
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            var output = ProxiedResolver.Resolve(request);

            if (output.IsSuccess)
            {
                return(output);
            }

            var registration = GetUnregisteredServiceRegistration(request);

            output = registrationResolver.Resolve(request, registration);
            MakeRegistrationAndResultAvailableToSubsequentResolutions(registration, output);

            return(output);
        }
예제 #7
0
 Func <object> GetObjectFactory(ResolutionRequest lazyRequest)
 {
     return(() => {
         var result = ProxiedResolver.Resolve(lazyRequest);
         if (!result.IsSuccess)
         {
             var message = String.Format(Resources.ExceptionFormats.LazyResolutionFailure,
                                         lazyRequest.ServiceType.FullName);
             throw new ResolutionException(message)
             {
                 ResolutionPath = lazyRequest.ResolutionPath
             };
         }
         return result.ResolvedObject;
     });
 }
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (request.ServiceType != typeof(string) || request.Name != RegisteredName)
            {
                return(ProxiedResolver.Resolve(request));
            }

            var currentResolutionPath = request.ResolutionPath;
            var resolvedName          = currentResolutionPath.CurrentRegistration.Name;

            var childResolutionPath = CreateRegisteredNameResolutionPath(currentResolutionPath, resolvedName);

            return(ResolutionResult.Success(childResolutionPath, resolvedName));
        }
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            var result = ProxiedResolver.Resolve(request);

            if (request.ServiceType != typeof(IObjectContainer) || !result.IsSuccess || request.ResolutionPath.IsEmpty)
            {
                return(result);
            }

            var container = (IObjectContainer)result.ResolvedObject;

            if (container is DynamicResolutionObjectContainerProxy)
            {
                return(result);
            }

            var dynamicContainer = new DynamicResolutionObjectContainerProxy((ObjectContainer)container, request.ResolutionPath);
            var registration     = GetFakeContainerRegistration(dynamicContainer, request.Name);

            return(ResolutionResult.Success(request.ResolutionPath, dynamicContainer));
        }
예제 #10
0
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            if (request.ServiceType != typeof(IResolvesServices) || request.ResolutionPath.IsEmpty)
            {
                return(ProxiedResolver.Resolve(request));
            }

            var containerRequest = new ResolutionRequest(typeof(IContainer), request.Name, request.ResolutionPath);
            var result           = ProxiedResolver.Resolve(containerRequest);

            if (!result.IsSuccess)
            {
                return(result);
            }

            var container        = (IContainer)result.ResolvedObject;
            var dynamicContainer = new ServiceResolvingContainerProxy(container, request.ResolutionPath);
            var registration     = GetFakeContainerRegistration(dynamicContainer, request.Name);

            return(ResolutionResult.Success(request.ResolutionPath, dynamicContainer));
        }
예제 #11
0
        /// <summary>
        /// Resolves the given resolution request and returns the result.
        /// </summary>
        /// <param name="request">Request.</param>
        public override ResolutionResult Resolve(ResolutionRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var registration = GetRegistration(request);
            var output       = ResolveFromCache(registration, request);

            if (output.IsSuccess)
            {
                return(output);
            }

            output = ProxiedResolver.Resolve(request);
            if (output.IsSuccess)
            {
                AddToCacheIfApplicable(registration, output.ResolvedObject);
            }

            return(output);
        }
        ResolutionResult ResolveSingleInstance(IServiceRegistration registration, ResolutionRequest request)
        {
            var subRequest = new ResolutionRequest(registration.ServiceType, registration.Name, request.ResolutionPath);

            return(ProxiedResolver.Resolve(subRequest));
        }