Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentRegistration"/> class.
        /// </summary>
        /// <param name="id">Unique identifier for the component.</param>
        /// <param name="activator">Activator used to activate instances.</param>
        /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
        /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
        /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
        /// <param name="pipelineBuilder">The resolve pipeline builder for the registration.</param>
        /// <param name="services">Services the component provides.</param>
        /// <param name="metadata">Data associated with the component.</param>
        /// <param name="options">The additional registration options.</param>
        public ComponentRegistration(
            Guid id,
            IInstanceActivator activator,
            IComponentLifetime lifetime,
            InstanceSharing sharing,
            InstanceOwnership ownership,
            IResolvePipelineBuilder pipelineBuilder,
            IEnumerable <Service> services,
            IDictionary <string, object?> metadata,
            RegistrationOptions options = RegistrationOptions.None)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            Id        = id;
            Activator = activator ?? throw new ArgumentNullException(nameof(activator));
            Lifetime  = lifetime ?? throw new ArgumentNullException(nameof(lifetime));
            Sharing   = sharing;
            Ownership = ownership;

            _lateBuildPipeline = pipelineBuilder;

            Services = Enforce.ArgumentElementNotNull(services, nameof(services));
            Metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
            Options  = options;
        }
Ejemplo n.º 2
0
        private static (RegistrationMode mode, bool valid) ConvertFromLifetime(IComponentLifetime lifetime, InstanceSharing sharing)
        {
            var instancePerDependency = lifetime is CurrentScopeLifetime && sharing == InstanceSharing.None;

            if (instancePerDependency)
            {
                return(RegistrationMode.InstancePerUse, true);
            }

            var singleInstance = lifetime is RootScopeLifetime && sharing == InstanceSharing.Shared;

            if (singleInstance)
            {
                return(RegistrationMode.Singleton, true);
            }

            var asMatchingScopeLifetime = lifetime as MatchingScopeLifetime;
            var instancePerRequest      = sharing == InstanceSharing.Shared && asMatchingScopeLifetime?.TagsToMatch.All(ttm => ttm == MatchingScopeLifetimeTags.RequestLifetimeScopeTag) == true;

            if (instancePerRequest)
            {
                return(RegistrationMode.InstancePerHttpRequest, true);
            }

            var instancePerLifetimeScope = lifetime is CurrentScopeLifetime && sharing == InstanceSharing.Shared;

            if (instancePerLifetimeScope)
            {
                return(default(RegistrationMode), false);
            }

            return(default(RegistrationMode), false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new component registration.
        /// </summary>
        /// <param name="id">Unique identifier for the component.</param>
        /// <param name="activator">Activator used to activate instances.</param>
        /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
        /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
        /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
        /// <param name="services">Services the component provides.</param>
        /// <param name="metadata">Data associated with the component.</param>
        public ComponentRegistration(
            Guid id,
            IInstanceActivator activator,
            IComponentLifetime lifetime,
            InstanceSharing sharing,
            InstanceOwnership ownership,
            IEnumerable <Service> services,
            IDictionary <string, object> metadata)
        {
            if (activator == null)
            {
                throw new ArgumentNullException(nameof(activator));
            }
            if (lifetime == null)
            {
                throw new ArgumentNullException(nameof(lifetime));
            }
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            Id        = id;
            Activator = activator;
            Lifetime  = lifetime;
            Sharing   = sharing;
            Ownership = ownership;
            Services  = Enforce.ArgumentElementNotNull(services, nameof(services)).ToList();
            Metadata  = new Dictionary <string, object>(metadata);
        }
        public ComponentRegistrationLifetimeDecorator(IComponentRegistration inner, IComponentLifetime lifetime)
        {
            if (inner == null) throw new ArgumentNullException("inner");
            if (lifetime == null) throw new ArgumentNullException("lifetime");

            _inner = inner;
            _lifetime = lifetime;
        }
Ejemplo n.º 5
0
 public ComponentRegistration(Guid id, IInstanceActivator activator, IComponentLifetime lifetime, InstanceSharing sharing, InstanceOwnership ownership, IEnumerable <Service> services, IDictionary <string, object> metadata)
 {
     this.Id        = id;
     this.Activator = Enforce.ArgumentNotNull <IInstanceActivator>(activator, "activator");
     this.Lifetime  = Enforce.ArgumentNotNull <IComponentLifetime>(lifetime, "lifetime");
     this.Sharing   = sharing;
     this.Ownership = ownership;
     this.Services  = Enforce.ArgumentElementNotNull <IEnumerable <Service> >(Enforce.ArgumentNotNull <IEnumerable <Service> >(services, "services"), "services").ToList <Service>();
     this.Metadata  = new Dictionary <string, object>(Enforce.ArgumentNotNull <IDictionary <string, object> >(metadata, "metadata"));
 }
Ejemplo n.º 6
0
 public static IComponentRegistration CreateRegistration(IEnumerable<Service> services, IInstanceActivator activator, IComponentLifetime lifetime, InstanceSharing sharing)
 {
     return new ComponentRegistration(
         Guid.NewGuid(),
         activator,
         lifetime,
         sharing,
         InstanceOwnership.OwnedByLifetimeScope,
         services,
         NoMetadata);
 }
 public OpenGenericRegistrationSource(
     IServiceWithType genericService,
     Type implementorType,
     IComponentLifetime lifetime,
     InstanceSharing sharing)
 {
     this.genericService  = genericService;
     this.implementorType = implementorType;
     this.lifetime        = lifetime;
     this.sharing         = sharing;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentRegistration"/> class.
 /// </summary>
 /// <param name="id">Unique identifier for the component.</param>
 /// <param name="activator">Activator used to activate instances.</param>
 /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
 /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
 /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
 /// <param name="services">Services the component provides.</param>
 /// <param name="metadata">Data associated with the component.</param>
 /// <param name="options">Contains options for the registration.</param>
 public ComponentRegistration(
     Guid id,
     IInstanceActivator activator,
     IComponentLifetime lifetime,
     InstanceSharing sharing,
     InstanceOwnership ownership,
     IEnumerable <Service> services,
     IDictionary <string, object?> metadata,
     RegistrationOptions options = RegistrationOptions.None)
     : this(id, activator, lifetime, sharing, ownership, new ResolvePipelineBuilder(PipelineType.Registration), services, metadata, options)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="System.Object" />
 ///     class.
 /// </summary>
 // ReSharper disable once UnusedMember.Global
 public ComponentRegistration(
     IComponentLifetime lifetime
     , InstanceSharing sharing
     , InstanceOwnership ownership
     , IComponentRegistration target
     )
 {
     Id        = Guid.NewGuid( );
     Lifetime  = lifetime;
     Sharing   = sharing;
     Ownership = ownership;
     Target    = target;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Create a new component registration.
 /// </summary>
 /// <param name="id">Unique identifier for the component.</param>
 /// <param name="activator">Activator used to activate instances.</param>
 /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
 /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
 /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
 /// <param name="services">Services the component provides.</param>
 /// <param name="metadata">Data associated with the component.</param>
 /// <param name="target">The component registration upon which this registration is based.</param>
 public ComponentRegistration(
     Guid id,
     IInstanceActivator activator,
     IComponentLifetime lifetime,
     InstanceSharing sharing,
     InstanceOwnership ownership,
     IEnumerable <Service> services,
     IDictionary <string, object> metadata,
     IComponentRegistration target)
     : this(id, activator, lifetime, sharing, ownership, services, metadata)
 {
     _target = Enforce.ArgumentNotNull(target, "target");
 }
Ejemplo n.º 11
0
		/// <summary>
		/// Create a new component registration.
		/// </summary>
		/// <param name="id">Unique identifier for the component.</param>
		/// <param name="activator">Activator used to activate instances.</param>
		/// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
		/// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
		/// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
		/// <param name="services">Services the component provides.</param>
		/// <param name="metadata">Data associated with the component.</param>
		/// <param name="target">The component registration upon which this registration is based.</param>
		public ComponentRegistration(
			Guid id,
			IInstanceActivator activator,
			IComponentLifetime lifetime,
			InstanceSharing sharing,
			InstanceOwnership ownership,
			IEnumerable<Service> services,
			IDictionary<string, object> metadata,
			IComponentRegistration target)
			: this(id, activator, lifetime, sharing, ownership, services, metadata)
		{
			_target = target;// Enforce.ArgumentNotNull(target, "target");
		}
Ejemplo n.º 12
0
 public ComponentRegistrationLifetimeDecorator(IComponentRegistration inner, IComponentLifetime lifetime)
 {
     if (inner == null)
     {
         throw new ArgumentNullException("inner");
     }
     if (lifetime == null)
     {
         throw new ArgumentNullException("lifetime");
     }
     this._inner    = inner;
     this._lifetime = lifetime;
 }
        private static IComponentLifetime GetLifetime(IComponentLifetime lifetime)
        {
            if (lifetime.GetType() == typeof(CurrentScopeLifetime))
            {
                return(new CurrentScopeLifetime());
            }

            if (lifetime.GetType() == typeof(RootScopeLifetime))
            {
                return(new RootScopeLifetime());
            }

            throw new NotSupportedException($"Lifetime scope '${lifetime.GetType().Name}' is not supported.");
        }
        public ComponentRegistrationLifetimeDecorator(IComponentRegistration inner, IComponentLifetime lifetime)
        {
            if (inner == null)
            {
                throw new ArgumentNullException(nameof(inner));
            }
            if (lifetime == null)
            {
                throw new ArgumentNullException(nameof(lifetime));
            }

            _inner   = inner;
            Lifetime = lifetime;
        }
 public ComponentHostedService(IComponentLifetime componentLifetime, IHostingEnvironment hostingEnvironment, IOptionAccessor <ApplicationOptions> optionAccessor)
 {
     _componentLifetime  = componentLifetime ?? throw new ArgumentNullException(nameof(componentLifetime));
     _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
     _applicationOptions = optionAccessor.Value;
     if (string.IsNullOrEmpty(_applicationOptions.ApplicationName))
     {
         _applicationOptions.ApplicationName = _hostingEnvironment.ApplicationName;
     }
     if (string.IsNullOrEmpty(_applicationOptions.Environment))
     {
         _applicationOptions.Environment = _hostingEnvironment.EnvironmentName;
     }
 }
Ejemplo n.º 16
0
        public LifetimeModel GetLifetimeModel(IComponentLifetime lifetime)
        {
            if (lifetime == null) throw new ArgumentNullException("lifetime");

            if (lifetime is CurrentScopeLifetime)
                return LifetimeModel.CurrentScope;

            if (lifetime is RootScopeLifetime)
                return LifetimeModel.RootScope;

            if (lifetime is MatchingScopeLifetime)
                return LifetimeModel.MatchingScope;

            return LifetimeModel.Other;
        }
Ejemplo n.º 17
0
        public ComponentRegistration(
            Guid id,
            IInstanceActivator activator,
            IComponentLifetime lifetime,
            InstanceSharing sharing,
            params Service[] services)
        {
            Id = id;

            Activator = activator;

            Lifetime = lifetime;

            Sharing = sharing;

            Services = services.ToArray();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Create a new component registration.
        /// </summary>
        /// <param name="id">Unique identifier for the component.</param>
        /// <param name="activator">Activator used to activate instances.</param>
        /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
        /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
        /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
        /// <param name="services">Services the component provides.</param>
        /// <param name="metadata">Data associated with the component.</param>
        /// <param name="target">The component registration upon which this registration is based.</param>
        public ComponentRegistration(
            Guid id,
            IInstanceActivator activator,
            IComponentLifetime lifetime,
            InstanceSharing sharing,
            InstanceOwnership ownership,
            IEnumerable <Service> services,
            IDictionary <string, object> metadata,
            IComponentRegistration target)
            : this(id, activator, lifetime, sharing, ownership, services, metadata)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            _target = target;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentRegistration"/> class.
        /// </summary>
        /// <param name="id">Unique identifier for the component.</param>
        /// <param name="activator">Activator used to activate instances.</param>
        /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
        /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
        /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
        /// <param name="pipelineBuilder">The resolve pipeline builder for the registration.</param>
        /// <param name="services">Services the component provides.</param>
        /// <param name="metadata">Data associated with the component.</param>
        /// <param name="target">The component registration upon which this registration is based.</param>
        /// <param name="options">Registration options.</param>
        public ComponentRegistration(
            Guid id,
            IInstanceActivator activator,
            IComponentLifetime lifetime,
            InstanceSharing sharing,
            InstanceOwnership ownership,
            IResolvePipelineBuilder pipelineBuilder,
            IEnumerable <Service> services,
            IDictionary <string, object?> metadata,
            IComponentRegistration target,
            RegistrationOptions options = RegistrationOptions.None)
            : this(id, activator, lifetime, sharing, ownership, pipelineBuilder, services, metadata, options)
        {
            _target = target ?? throw new ArgumentNullException(nameof(target));

            // Certain flags carry over from the target.
            Options = options | (_target.Options & OptionsCopiedFromTargetRegistration);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Create a new component registration.
 /// </summary>
 /// <param name="id">Unique identifier for the component.</param>
 /// <param name="activator">Activator used to activate instances.</param>
 /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
 /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
 /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
 /// <param name="services">Services the component provides.</param>
 /// <param name="metadata">Data associated with the component.</param>
 public ComponentRegistration(
     Guid id,
     IInstanceActivator activator,
     IComponentLifetime lifetime,
     InstanceSharing sharing,
     InstanceOwnership ownership,
     IEnumerable <Service> services,
     IDictionary <string, object> metadata)
 {
     Id        = id;
     Activator = Enforce.ArgumentNotNull(activator, "activator");
     Lifetime  = Enforce.ArgumentNotNull(lifetime, "lifetime");
     Sharing   = sharing;
     Ownership = ownership;
     Services  = Enforce.ArgumentElementNotNull(
         Enforce.ArgumentNotNull(services, "services"), "services").ToList();
     Metadata = new Dictionary <string, object>(
         Enforce.ArgumentNotNull(metadata, "metadata"));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Create a new component registration.
 /// </summary>
 /// <param name="id">Unique identifier for the component.</param>
 /// <param name="activator">Activator used to activate instances.</param>
 /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
 /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
 /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
 /// <param name="services">Services the component provides.</param>
 /// <param name="metadata">Data associated with the component.</param>
 public ComponentRegistration(
     Guid id,
     IInstanceActivator activator,
     IComponentLifetime lifetime,
     InstanceSharing sharing,
     InstanceOwnership ownership,
     IEnumerable<Service> services,
     IDictionary<string, object> metadata)
 {
     Id = id;
     Activator = Enforce.ArgumentNotNull(activator, "activator");
     Lifetime = Enforce.ArgumentNotNull(lifetime, "lifetime");
     Sharing = sharing;
     Ownership = ownership;
     Services = Enforce.ArgumentElementNotNull(
         Enforce.ArgumentNotNull(services, "services"), "services").ToList();
     Metadata = new Dictionary<string, object>(
         Enforce.ArgumentNotNull(metadata, "metadata"));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Create a new component registration.
 /// </summary>
 /// <param name="id">Unique identifier for the component.</param>
 /// <param name="activator">Activator used to activate instances.</param>
 /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
 /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
 /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
 /// <param name="services">Services the component provides.</param>
 /// <param name="metadata">Data associated with the component.</param>
 public ComponentRegistration(
     Guid id,
     IInstanceActivator activator,
     IComponentLifetime lifetime,
     InstanceSharing sharing,
     InstanceOwnership ownership,
     IEnumerable <Service> services,
     IDictionary <string, object> metadata)
 {
     Id        = id;
     Activator = activator;          // Enforce.ArgumentNotNull(activator, "activator");
     Lifetime  = lifetime;           // Enforce.ArgumentNotNull(lifetime, "lifetime");
     Sharing   = sharing;
     Ownership = ownership;
     //var list = new List<Service>(services);
     //if (list.Contains(null))
     //Enforce.ArgumentElementNotNull(services, "services");
     Services = services;
     Metadata = metadata;            //new Dictionary<string, object>(Enforce.ArgumentNotNull(metadata, "metadata"));
 }
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="activator"></param>
 /// <param name="lifetime"></param>
 /// <param name="sharing"></param>
 /// <param name="ownership"></param>
 /// <param name="services"></param>
 /// <param name="metadata"></param>
 /// <param name="serviceDescriptor"></param>
 public ServiceDescriptorComponentRegistration(
     Guid id,
     IInstanceActivator activator,
     IComponentLifetime lifetime,
     InstanceSharing sharing,
     InstanceOwnership ownership,
     IEnumerable <Service> services,
     IDictionary <string, object> metadata,
     ServiceDescriptor serviceDescriptor) :
     base(
         id,
         activator,
         lifetime,
         sharing,
         ownership,
         services,
         metadata)
 {
     this.serviceDescriptor = serviceDescriptor ?? throw new ArgumentNullException(nameof(serviceDescriptor));
 }
Ejemplo n.º 24
0
		/// <summary>
		/// Create a new component registration.
		/// </summary>
		/// <param name="id">Unique identifier for the component.</param>
		/// <param name="activator">Activator used to activate instances.</param>
		/// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
		/// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
		/// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
		/// <param name="services">Services the component provides.</param>
		/// <param name="metadata">Data associated with the component.</param>
		public ComponentRegistration(
			Guid id,
			IInstanceActivator activator,
			IComponentLifetime lifetime,
			InstanceSharing sharing,
			InstanceOwnership ownership,
			IEnumerable<Service> services,
			IDictionary<string, object> metadata)
		{
			Id = id;
			Activator = activator;// Enforce.ArgumentNotNull(activator, "activator");
			Lifetime = lifetime;// Enforce.ArgumentNotNull(lifetime, "lifetime");
			Sharing = sharing;
			Ownership = ownership;
			//var list = new List<Service>(services);
			//if (list.Contains(null))
			//Enforce.ArgumentElementNotNull(services, "services");
			Services = services;
			Metadata = metadata;//new Dictionary<string, object>(Enforce.ArgumentNotNull(metadata, "metadata"));
		}
Ejemplo n.º 25
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="System.Object" />
 ///     class.
 /// </summary>
 // ReSharper disable once UnusedMember.Global
 public ComponentRegistration(
     Guid id
     , IInstanceActivator activator
     , IComponentLifetime lifetime
     , InstanceSharing sharing
     , InstanceOwnership ownership
     , IEnumerable <Service> services
     , IDictionary <string, object> metadata
     , IComponentRegistration target
     )
 {
     Id        = id;
     Activator = activator;
     Lifetime  = lifetime;
     Sharing   = sharing;
     Ownership = ownership;
     Services  = services;
     Metadata  = metadata;
     Target    = target;
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Create a new component registration.
        /// </summary>
        /// <param name="id">Unique identifier for the component.</param>
        /// <param name="activator">Activator used to activate instances.</param>
        /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
        /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
        /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
        /// <param name="services">Services the component provides.</param>
        /// <param name="metadata">Data associated with the component.</param>
        public ComponentRegistration(
            Guid id,
            IInstanceActivator activator,
            IComponentLifetime lifetime,
            InstanceSharing sharing,
            InstanceOwnership ownership,
            IEnumerable<Service> services,
            IDictionary<string, object> metadata)
        {
            if (activator == null) throw new ArgumentNullException(nameof(activator));
            if (lifetime == null) throw new ArgumentNullException(nameof(lifetime));
            if (services == null) throw new ArgumentNullException(nameof(services));
            if (metadata == null) throw new ArgumentNullException(nameof(metadata));

            Id = id;
            Activator = activator;
            Lifetime = lifetime;
            Sharing = sharing;
            Ownership = ownership;
            Services = Enforce.ArgumentElementNotNull(services, nameof(services)).ToList();
            Metadata = new Dictionary<string, object>(metadata);
        }
        public ComponentRegistration(
            Service service,
            IInstanceActivator activator,
            IComponentLifetime lifetime,
            InstanceSharing sharing)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (activator == null)
            {
                throw new ArgumentNullException(nameof(activator));
            }
            if (lifetime == null)
            {
                throw new ArgumentNullException(nameof(lifetime));
            }

            Service   = service;
            Activator = activator;
            Lifetime  = lifetime;
            Sharing   = sharing;
        }
Ejemplo n.º 28
0
        public LifetimeModel GetLifetimeModel(IComponentLifetime lifetime)
        {
            if (lifetime == null)
            {
                throw new ArgumentNullException("lifetime");
            }

            if (lifetime is CurrentScopeLifetime)
            {
                return(LifetimeModel.CurrentScope);
            }

            if (lifetime is RootScopeLifetime)
            {
                return(LifetimeModel.RootScope);
            }

            if (lifetime is MatchingScopeLifetime)
            {
                return(LifetimeModel.MatchingScope);
            }

            return(LifetimeModel.Other);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScopeRestrictedRegisteredServicesTracker"/> class.
 /// </summary>
 /// <param name="restrictedRootScopeLifetime">The scope to which registrations are restricted.</param>
 internal ScopeRestrictedRegisteredServicesTracker(IComponentLifetime restrictedRootScopeLifetime)
 {
     _restrictedRootScopeLifetime = restrictedRootScopeLifetime;
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Create a new component registration.
        /// </summary>
        /// <param name="id">Unique identifier for the component.</param>
        /// <param name="activator">Activator used to activate instances.</param>
        /// <param name="lifetime">Determines how the component will be associated with its lifetime.</param>
        /// <param name="sharing">Whether the component is shared within its lifetime scope.</param>
        /// <param name="ownership">Whether the component instances are disposed at the end of their lifetimes.</param>
        /// <param name="services">Services the component provides.</param>
        /// <param name="metadata">Data associated with the component.</param>
        /// <param name="target">The component registration upon which this registration is based.</param>
        public ComponentRegistration(
            Guid id,
            IInstanceActivator activator,
            IComponentLifetime lifetime,
            InstanceSharing sharing,
            InstanceOwnership ownership,
            IEnumerable<Service> services,
            IDictionary<string, object> metadata,
            IComponentRegistration target)
            : this(id, activator, lifetime, sharing, ownership, services, metadata)
        {
            if (target == null) throw new ArgumentNullException(nameof(target));

            _target = target;
        }
Ejemplo n.º 31
0
 public ScopeRestrictedRegistry(object scopeTag)
 {
     _restrictedRootScopeLifetime = new MatchingScopeLifetime(scopeTag);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentRegistrationLifetimeDecorator"/> class.
 /// </summary>
 /// <param name="inner">The inner registration.</param>
 /// <param name="lifetime">The enforced lifetime.</param>
 public ComponentRegistrationLifetimeDecorator(IComponentRegistration inner, IComponentLifetime lifetime)
 {
     _inner   = inner ?? throw new ArgumentNullException(nameof(inner));
     Lifetime = lifetime ?? throw new ArgumentNullException(nameof(lifetime));
 }
Ejemplo n.º 33
0
 public ComponentHostedService(IComponentLifetime componentLifetime)
 {
     _componentLifetime = componentLifetime ?? throw new ArgumentNullException(nameof(componentLifetime));
 }
Ejemplo n.º 34
0
 public ScopeRestrictedRegistry(object scopeTag)
 {
     _restrictedRootScopeLifetime = new MatchingScopeLifetime(scopeTag);
 }
Ejemplo n.º 35
0
 public ExternalComponentRegistration(Guid id, IInstanceActivator activator, IComponentLifetime lifetime, InstanceSharing sharing, InstanceOwnership ownership, IEnumerable <Service> services, IDictionary <string, object?> metadata, IComponentRegistration target, bool isAdapterForIndividualComponent)
     : base(id, activator, lifetime, sharing, ownership, services, metadata, target, isAdapterForIndividualComponent)
 {
 }
Ejemplo n.º 36
0
        public RegistrationData(Service defaultService)
        {
            _defaultService = defaultService;

            Lifetime = new CurrentLifetimeScope();
        }
Ejemplo n.º 37
0
 internal ScopeRestrictedRegistry(object scopeTag, IDictionary <string, object> properties)
     : base(properties)
 {
     _restrictedRootScopeLifetime = new MatchingScopeLifetime(scopeTag);
 }
Ejemplo n.º 38
0
 public static IComponentRegistration CreateRegistration(IEnumerable <Service> services, IInstanceActivator activator, IComponentLifetime lifetime, InstanceSharing sharing)
 {
     return(new ComponentRegistration(
                Guid.NewGuid(),
                activator,
                lifetime,
                sharing,
                InstanceOwnership.OwnedByLifetimeScope,
                services,
                GetDefaultMetadata()));
 }