IServiceRegistration GetFakeContainerRegistration(DynamicResolutionObjectContainerProxy instance, string name) { return(new FactoryRegistration(new Func <IObjectContainer>(() => instance)) { ServiceType = typeof(IObjectContainer), Name = name, Cacheable = false, DisposeWithContainer = false, }); }
/// <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)); }