/// <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; }
public ApiConfigurationProvider(IServiceProvider appServices, IInstanceActivator activator, IArrayMethodInvokerBuilder invokerBuilder, IOptions <RpcServiceConfiguration> rpcConfiguration) { _activator = activator; _invokerBuilder = invokerBuilder; _rpcConfiguration = rpcConfiguration; AppServices = appServices; }
/// <summary> /// Default constructor /// </summary> /// <param name="types"></param> /// <param name="apiInformation"></param> /// <param name="activator"></param> public TypeSetExposureConfiguration(IEnumerable <Type> types, ICurrentApiInformation apiInformation, IInstanceActivator activator, IArrayMethodInvokerBuilder invokerBuilder) { _types = types; _apiInformation = apiInformation; _activator = activator; _invokerBuilder = invokerBuilder; }
/// <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 ObjectPortal_DPWrapper(ILifetimeScope scope, Func <IMobileObjectWrapper <T> > createFunc, DataPortal <IMobileObjectWrapper <T> > dataPortal) { this.dataPortal = dataPortal; this.scope = scope; //first check T and see if we are getting and abstract or interface type - if we are - we can use the scope to resolve T //if T is not an interface or abstract - then we don't even need to check the container for it - just use the type directly Type genericType = typeof(T); if (genericType.IsInterface || genericType.IsAbstract) { IComponentRegistration registration = scope.ComponentRegistry.RegistrationsFor(new TypedService(genericType)).FirstOrDefault(); if (registration != null) { IInstanceActivator activator = registration.Activator as IInstanceActivator; if (activator != null) { _concreteType = activator.LimitType; } } if (_concreteType == null) { throw new Exception($"Cannot find registration for {_concreteType.FullName}"); } } else { //if we were given a non-abstract type already - then just use it _concreteType = typeof(T); } this.createMobileObjectWrapper = createFunc; }
/// <summary> /// Create an IComponentRegistration from data. /// </summary> /// <param name="id">Id of the registration.</param> /// <param name="data">Registration data.</param> /// <param name="activator">Activator.</param> /// <param name="services">Services provided by the registration.</param> /// <param name="target">Optional; target registration.</param> /// <returns>An IComponentRegistration.</returns> public static IComponentRegistration CreateRegistration( Guid id, RegistrationData data, IInstanceActivator activator, IEnumerable <Service> services, IComponentRegistration target) { //TODO: this probably protects against some invalid registrations, but since none of the tests fail, let's ignore it for now /*var limitType = activator.LimitType; * if (limitType != typeof(object)) * foreach (var ts in services.OfType<IServiceWithType>()) * if (!ts.ServiceType.IsAssignableFrom(limitType)) * throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, * RegistrationBuilderResources.ComponentDoesNotSupportService, limitType, ts)); */ IComponentRegistration registration; if (target == null) { registration = new ComponentRegistration( id, activator, data.Lifetime, data.Sharing, data.Ownership, services, data.Metadata); } else { registration = new ComponentRegistration( id, activator, data.Lifetime, data.Sharing, data.Ownership, services, data.Metadata, target); } foreach (var p in data.PreparingHandlers) { registration.Preparing += p; } foreach (var ac in data.ActivatingHandlers) { registration.Activating += ac; } foreach (var ad in data.ActivatedHandlers) { registration.Activated += ad; } return(registration); }
// This shorthand name for the activator is used in exception messages; for activator types // where the limit type generally describes the activator exactly, we use that; for delegate // activators, a variation on the type name is used to indicate this. public static string DisplayName(this IInstanceActivator activator) { var fullName = activator.LimitType.FullName ?? ""; return(activator is DelegateActivator ? $"λ:{fullName}" : fullName); }
/// <summary> /// Create an IComponentRegistration from data. /// </summary> /// <param name="id">Id of the registration.</param> /// <param name="data">Registration data.</param> /// <param name="activator">Activator.</param> /// <param name="services">Services provided by the registration.</param> /// <returns>An IComponentRegistration.</returns> public static IComponentRegistration CreateRegistration( Guid id, RegistrationData data, IInstanceActivator activator, IEnumerable <Service> services) { return(CreateRegistration(id, data, activator, services, null)); }
public ProfilingActivator( IComponentRegistration registration, IInstanceActivator innerActivator, ContainerProfile profile) { _registration = registration; _innerActivator = innerActivator; _profile = profile; }
public ProfilingActivator( IComponentRegistration registration, IInstanceActivator innerActivator, ContainerProfile profile) { _registration = registration; _innerActivator = innerActivator; _profile = profile; }
/// <summary> /// Create an IComponentRegistration from data. /// </summary> /// <param name="id">Id of the registration.</param> /// <param name="data">Registration data.</param> /// <param name="activator">Activator.</param> /// <param name="pipelineBuilder">The component registration's resolve pipeline builder.</param> /// <param name="services">Services provided by the registration.</param> /// <returns>An IComponentRegistration.</returns> public static IComponentRegistration CreateRegistration( Guid id, RegistrationData data, IInstanceActivator activator, IResolvePipelineBuilder pipelineBuilder, Service[] services) { return(CreateRegistration(id, data, activator, pipelineBuilder, services, null)); }
/// <summary> /// Initializes a new instance of the <see cref="SimpleActivatorData"/> class. /// </summary> /// <param name="activator">The activator to return.</param> public SimpleActivatorData(IInstanceActivator activator) { if (activator == null) { throw new ArgumentNullException(nameof(activator)); } Activator = activator; }
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")); }
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); }
/// <summary> /// This shorthand name for the activator is used in exception messages; for activator types /// where the limit type generally describes the activator exactly, we use that; for delegate /// activators, a variation on the type name is used to indicate this. /// </summary> /// <param name="activator">The activator instance.</param> /// <returns>A display name.</returns> public static string DisplayName(this IInstanceActivator activator) { // There is a similar class in the Autofac core library but // this gives us full control over display in the graph as // well as not requiring DisplayName be part of the public API. var fullName = activator?.LimitType.CSharpName() ?? ""; return(activator is DelegateActivator ? $"λ:{fullName}" : fullName); }
/// <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) { }
/// <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"); }
/// <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"); }
public ComponentRegistration(Service service, IInstanceActivator activator) { if (service == null) { throw new ArgumentNullException(nameof(service)); } if (activator == null) { throw new ArgumentNullException(nameof(activator)); } Service = service; Activator = activator; }
public ActivatorModel GetActivatorModel(IInstanceActivator activator) { if (activator == null) throw new ArgumentNullException("activator"); if (activator is ReflectionActivator) return ActivatorModel.Reflection; if (activator is DelegateActivator) return ActivatorModel.Delegate; if (activator is ProvidedInstanceActivator) return ActivatorModel.ProvidedInstance; return ActivatorModel.Other; }
public RpcMessageProcessor(IOptions <RpcServiceConfiguration> configuration, IContentEncodingProvider contentEncodingProvider, IContentSerializerProvider contentSerializerProvider, IExposeMethodInformationCacheManager cacheManager, IInstanceActivator activator, ILogger <RpcMessageProcessor> logger = null) { _configuration = configuration; _contentEncodingProvider = contentEncodingProvider; _contentSerializerProvider = contentSerializerProvider; _cacheManager = cacheManager; _activator = activator; _logger = logger; _debugLogging = configuration.Value.DebugLogging; _defaultSerializer = _contentSerializerProvider.DefaultSerializer; }
public ActivationRegistrationData( IInstanceActivator activator, Type implementatorType) { if (activator == null) { throw new ArgumentNullException(nameof(activator)); } if (implementatorType == null) { throw new ArgumentNullException(nameof(implementatorType)); } Activator = activator; ImplementatorType = implementatorType; }
private static DependencyResolutionException PropagateActivationException(IInstanceActivator activator, Exception exception) { var activatorChain = activator.DisplayName(); var innerException = exception; if (exception.Data.Contains(ActivatorChainExceptionData) && exception.Data[ActivatorChainExceptionData] is string innerChain) { activatorChain = activatorChain + " -> " + innerChain; innerException = exception.InnerException; } var result = new DependencyResolutionException(string.Format(CultureInfo.CurrentCulture, ComponentActivationResources.ErrorDuringActivation, activatorChain), innerException); result.Data[ActivatorChainExceptionData] = activatorChain; return(result); }
public ComponentRegistration( Guid id, IInstanceActivator activator, IComponentLifetime lifetime, InstanceSharing sharing, params Service[] services) { Id = id; Activator = activator; Lifetime = lifetime; Sharing = sharing; Services = services.ToArray(); }
/// <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; }
public InstanceActivator(IInstanceActivator activator) { this.activator = activator; var reflectionActivator = activator as ReflectionActivator; if (reflectionActivator != null) { this.constructorFinder = reflectionActivator.ConstructorFinder; this.constructorSelector = reflectionActivator.ConstructorSelector; this._defaultParameters = (IEnumerable <Parameter>)_defaultParametersField.GetValue(reflectionActivator); } else { this.constructorFinder = new DefaultConstructorFinder(); this.constructorSelector = new MostParametersConstructorSelector(); this._defaultParameters = new Parameter[] { new AutowiringParameter(), new DefaultValueParameter() }; } }
/// <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); }
/// <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")); }
/// <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")); }
/// <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)); }
/// <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> /// 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 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; }
/// <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 ActivatorModel GetActivatorModel(IInstanceActivator activator) { if (activator == null) { throw new ArgumentNullException("activator"); } if (activator is ReflectionActivator) { return(ActivatorModel.Reflection); } if (activator is DelegateActivator) { return(ActivatorModel.Delegate); } if (activator is ProvidedInstanceActivator) { return(ActivatorModel.ProvidedInstance); } return(ActivatorModel.Other); }
public ExposedMethodInformation(Type type, IEnumerable <string> routeNames, string methodName, MethodInfo method, IMethodAuthorization[] methodAuthorizations, Func <ICallExecutionContext, IEnumerable <ICallFilter> >[] filters, IInstanceActivator instanceActivator, IArrayMethodInvokerBuilder invokeMethodBuilder, bool allowCompression, string obsoleteMessage) { _invokeMethodBuilder = invokeMethodBuilder; _allowCompression = allowCompression; Type = type; RouteNames = routeNames; MethodName = methodName; MethodInfo = method; MethodAuthorizations = methodAuthorizations; Filters = filters; ObsoleteMessage = obsoleteMessage; InstanceType = MethodInfo.DeclaringType; InstanceProvider = (context, provider) => instanceActivator.ActivateInstance(context, provider, Type); Parameters = GenerateParameters(); }
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; }
/// <summary> /// Return the provided activator. /// </summary> /// <param name="activator">The activator to return.</param> public SimpleActivatorData(IInstanceActivator activator) { _activator = Enforce.ArgumentNotNull(activator, "activator"); }
/// <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; }
/// <summary> /// Return the provided activator. /// </summary> /// <param name="activator">The activator to return.</param> public SimpleActivatorData(IInstanceActivator activator) { if (activator == null) throw new ArgumentNullException(nameof(activator)); Activator = activator; }
public DecoratorInstanceActivator(IInstanceActivator actualActivator, IEnumerable<IResolvingObserver> observers) { _actualActivator = actualActivator; _observers = observers; }
public static IComponentRegistration CreateSingletonRegistration(IEnumerable<Service> services, IInstanceActivator activator) { return CreateRegistration(services, activator, new RootScopeLifetime(), InstanceSharing.Shared); }