コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManyObjectsResolverBase{TResolver, TResolved}"/> class with an empty list of objects,
        /// and an optional lifetime scope.
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="logger"></param>
        /// <param name="scope">The lifetime scope of instantiated objects, default is per Application.</param>
        /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
        /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
        protected ManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            CanResolveBeforeFrozen = false;
            if (scope == ObjectLifetimeScope.HttpRequest)
            {
                _httpContextGetter = () => new HttpContextWrapper(HttpContext.Current);
            }

            ServiceProvider = serviceProvider;
            Logger          = logger;
            LifetimeScope   = scope;
            if (scope == ObjectLifetimeScope.HttpRequest)
            {
                _httpContextKey = GetType().FullName;
            }
            _instanceTypes = new List <Type>();

            InitializeAppInstances();
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManyObjectsResolverBase{TResolver, TResolved}"/> class with an empty list of objects,
        /// and an optional lifetime scope.
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="logger"></param>
        /// <param name="scope">The lifetime scope of instantiated objects, default is per Application.</param>
        /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
        /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
        protected ManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            CanResolveBeforeFrozen = false;
            if (scope == ObjectLifetimeScope.HttpRequest)
            {
                if (HttpContext.Current == null)
                {
                    throw new InvalidOperationException("Use alternative constructor accepting a HttpContextBase object in order to set the lifetime scope to HttpRequest when HttpContext.Current is null");
                }

                CurrentHttpContext = new HttpContextWrapper(HttpContext.Current);
            }

            ServiceProvider = serviceProvider;
            Logger          = logger;
            LifetimeScope   = scope;
            if (scope == ObjectLifetimeScope.HttpRequest)
            {
                _httpContextKey = GetType().FullName;
            }
            _instanceTypes = new List <Type>();

            InitializeAppInstances();
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManyObjectsResolverBase{TResolver, TResolved}"/> class with an empty list of objects.
        /// </summary>
        /// <param name="scope">The lifetime scope of instantiated objects, default is per Application</param>
        protected ManyObjectsResolverBase(ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
        {
            CanResolveBeforeFrozen = false;
            if (scope == ObjectLifetimeScope.HttpRequest)
            {
                if (HttpContext.Current == null)
                {
                    throw new InvalidOperationException("Use alternative constructor accepting a HttpContextBase object in order to set the lifetime scope to HttpRequest when HttpContext.Current is null");
                }
                CurrentHttpContext = new HttpContextWrapper(HttpContext.Current);
            }

            LifetimeScope = scope;
            InstanceTypes = new List <Type>();
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManyObjectsResolverBase{TResolver, TResolved}"/> class with an initial list of objects.
 /// </summary>
 /// <param name="value">The list of objects.</param>
 /// <param name="scope">If set to true will resolve singleton objects which will be created once for the lifetime of the application</param>
 protected ManyObjectsResolverBase(IEnumerable <Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(scope)
 {
     InstanceTypes = new List <Type>(value);
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LazyManyObjectsResolverBase{TResolver, TResolved}"/> class with an initial list
 /// of functions producing types, and an optional lifetime scope.
 /// </summary>
 /// <param name="typeListProducerList">The list of functions producing types.</param>
 /// <param name="scope">The lifetime scope of instantiated objects, default is per Application.</param>
 /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
 /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
 protected LazyManyObjectsResolverBase(Func <IEnumerable <Type> > typeListProducerList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(scope)
 {
     _typeListProducerList.Add(typeListProducerList);
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LazyManyObjectsResolverBase{TResolver, TResolved}"/> class with an empty list of objects,
 /// with creation of objects based on an HttpRequest lifetime scope.
 /// </summary>
 /// <param name="scope">The lifetime scope of instantiated objects, default is per Application.</param>
 /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
 /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
 protected LazyManyObjectsResolverBase(ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : base(scope)
 {
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LazyManyObjectsResolverBase{TResolver, TResolved}"/> class with an initial list
 /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
 /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
 protected LazyManyObjectsResolverBase(IEnumerable <Lazy <Type> > lazyTypeList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(scope)
 {
     AddTypes(lazyTypeList);
 }
コード例 #8
0
 public ManyResolver(IEnumerable <Type> value, ObjectLifetimeScope scope)
     : base(value, scope)
 {
 }
コード例 #9
0
 /// <summary>
 /// Constructor accepting a delegate to return a list of types
 /// </summary>
 /// <param name="typeListDelegate"></param>
 /// <param name="scope"></param>
 protected LazyManyObjectsResolverBase(Func <IEnumerable <Type> > typeListDelegate, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(scope)
 {
     _listOfTypeListDelegates.Add(typeListDelegate);
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManyObjectsResolverBase{TResolver, TResolved}"/> class with an initial list of object types,
 /// and an optional lifetime scope.
 /// </summary>
 /// <param name="value">The list of object types.</param>
 /// <param name="scope">The lifetime scope of instantiated objects, default is per Application.</param>
 /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
 /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
 protected ManyObjectsResolverBase(IEnumerable <Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(scope)
 {
     _instanceTypes = value.ToList();
 }
コード例 #11
0
 public ManyResolver(IServiceProvider serviceProvider, ILogger logger, IEnumerable <Type> value, ObjectLifetimeScope scope)
     : base(serviceProvider, logger, value, scope)
 {
 }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManyObjectsResolverBase{TResolver, TResolved}"/> class with an initial list of object types,
 /// and an optional lifetime scope.
 /// </summary>
 /// <param name="serviceProvider"></param>
 /// <param name="logger"></param>
 /// <param name="value">The list of object types.</param>
 /// <param name="scope">The lifetime scope of instantiated objects, default is per Application.</param>
 /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
 /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
 protected ManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, IEnumerable <Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(serviceProvider, logger, scope)
 {
     _instanceTypes = value.ToList();
 }
コード例 #13
0
 protected ManyObjectsResolverBase(IEnumerable <Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(new ActivatorServiceProvider(), LoggerResolver.Current.Logger, value, scope)
 {
 }
コード例 #14
0
 protected LazyManyObjectsResolverBase(Func <IEnumerable <Type> > typeListProducerList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(new ActivatorServiceProvider(), LoggerResolver.Current.Logger, typeListProducerList, scope)
 {
 }
コード例 #15
0
 protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, Func <IEnumerable <Type> > typeListProducerList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(serviceProvider, logger, scope)
 {
     _typeListProducerList.Add(typeListProducerList);
 }
コード例 #16
0
 protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, IEnumerable <Lazy <Type> > lazyTypeList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(serviceProvider, logger, scope)
 {
     AddTypes(lazyTypeList);
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManyObjectsResolverBase{TResolver, TResolved}"/> class with an empty list of objects,
 /// and an optional lifetime scope.
 /// </summary>
 /// <param name="serviceProvider"></param>
 /// <param name="logger"></param>
 /// <param name="scope">The lifetime scope of instantiated objects, default is per Application.</param>
 /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
 /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
 protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : base(serviceProvider, logger, scope)
 {
     Initialize();
 }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManyObjectsResolverBase{TResolver, TResolved}"/> class with an initial list of object types,
 /// and an optional lifetime scope.
 /// </summary>
 /// <param name="serviceProvider"></param>
 /// <param name="logger"></param>
 /// <param name="value">The list of object types.</param>
 /// <param name="scope">The lifetime scope of instantiated objects, default is per Application.</param>
 /// <remarks>If <paramref name="scope"/> is per HttpRequest then there must be a current HttpContext.</remarks>
 /// <exception cref="InvalidOperationException"><paramref name="scope"/> is per HttpRequest but the current HttpContext is null.</exception>
 protected LazyManyObjectsResolverBase(IServiceProvider serviceProvider, ILogger logger, IEnumerable <Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : base(serviceProvider, logger, value, scope)
 {
 }
コード例 #19
0
 internal GraphQLValueResolversResolver(IServiceProvider serviceProvider, ILogger logger,
                                        IEnumerable <Type> value, ObjectLifetimeScope scope = ObjectLifetimeScope.Application) : base(
         serviceProvider, logger, value, scope)
 {
 }
コード例 #20
0
 protected ManyObjectsResolverBase(ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
     : this(new ActivatorServiceProvider(), LoggerResolver.Current.Logger, scope)
 {
 }