public InstanceProviderFactory( IInstanceProvider instanceProvider) { Requires.NotNull(instanceProvider, nameof(instanceProvider)); this.instanceProvider = instanceProvider; }
public Pool(IInstanceProvider instanceProvider, int size) { this.instanceProvider = instanceProvider; instances = new List <T>(size); Capacity = size; Add(size); }
public override void CleanUpMethod() { base.CleanUpMethod(); _logDbContextProvider = null; _logic = null; }
public HUtils(IInstanceProvider instanceProvider) { configService = instanceProvider.GetInstance <IConfigService>(); fullscreenAdsModel = instanceProvider.GetInstance <IFullscreenAdsModel>(); lifetimeStatistics = instanceProvider.GetInstance <ILifetimeStatistics>(); showCustomAdSignal = instanceProvider.GetInstance <ShowCustomAdSignal>(); }
/// <summary> /// Creates an instance of this exception. /// </summary> /// <param name="context">The context in which the instance was requested.</param> /// <param name="name">The name of the instance that was requested.</param> /// <param name="instanceProvider">The instance provider, which was unable to provide an instance of the specified type.</param> /// <param name="reason"></param> internal IncompatibleInstanceTypeException(IContext context, RIName name, IInstanceProvider instanceProvider, string reason) : base($"The instance by the name '{name}' cannot be instantiated. {reason}") { Context = context; Name = name; InstanceProvider = instanceProvider; }
public ServiceHost(Uri uri, IInstanceProvider instanceProvider) : base(typeof(TImpl), uri) { foreach (var contract in ImplementedContracts) { contract.Value.ContractBehaviors.Add(new InstanceProviderBehaviour(instanceProvider)); } }
public Pool( IInstanceProvider instanceProvider) { Requires.NotNull(instanceProvider, nameof(instanceProvider)); this.instanceProvider = instanceProvider; }
public CompareRunner(IInstanceProvider instanceProvider, ISolver exactSolver, ISolver solver) { this.exactSolver = exactSolver; this.solver = solver; instances = instanceProvider.GetInstances(); }
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= public CmdLineExecutor(ClassDefinition classDefinition, IInstanceProvider instanceProvider) { Defintion = classDefinition ?? throw new ArgumentNullException(nameof(classDefinition)); InstanceProvider = instanceProvider; Type = instanceProvider.TypeOf; Instance = instanceProvider.Instance; }
public void Init(ResourceManager rm, IInstanceProvider instanceProvider, InstantiationParameters instantiationParams, AsyncOperationHandle <GameObject> dependency) { m_RM = rm; m_dependency = dependency; m_instanceProvider = instanceProvider; m_instantiationParams = instantiationParams; }
public InstanceProviderSingleton( IInstanceProvider instanceProvider) { Requires.NotNull(instanceProvider, nameof(instanceProvider)); this.instanceProvider = instanceProvider; }
private IInstanceProvider GetInstanceProvider() { if (_instanceProvider == null) { _instanceProvider = _context.GetInstanceProvider(Reference); } return(_instanceProvider); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceLocationContractBehavior"/> class. /// </summary> /// <param name="instanceProvider">The instance provider.</param> public ServiceLocationContractBehavior(IInstanceProvider instanceProvider) { if (instanceProvider == null) { throw new ArgumentNullException("instanceProvider"); } _instanceProvider = instanceProvider; }
public static IContractInvoker Use <TContract>( this IBoltRouteHandler bolt, IInstanceProvider instanceProvider, Action <ConfigureContractContext> configure = null, ServerRuntimeConfiguration configuration = null) { return(bolt.Use(typeof(TContract), instanceProvider, configure, configuration)); }
public DIContainerContractBehavior(IInstanceProvider instanceProvider) { if (instanceProvider == null) { throw new ArgumentNullException("instanceProvider"); } this.instanceProvider = instanceProvider; }
public UnityContractBehavior(IInstanceProvider instanceProvider) { if (instanceProvider == null) { throw new ArgumentNullException("instanceProvider"); } _instanceProvider = instanceProvider; }
internal DispatchRuntime(ClientRuntime proxyRuntime, SharedRuntimeState shared) : this(shared) { ClientRuntime = proxyRuntime ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(proxyRuntime)); _instanceProvider = new CallbackInstanceProvider(); _channelDispatcher = new ChannelDispatcher(shared); _instanceContextProvider = InstanceContextProviderBase.GetProviderForMode(InstanceContextMode.PerSession, this); Fx.Assert(!shared.IsOnServer, "Client constructor called on server?"); }
public DockerBindInstanceProviderTest() : base() { IOptions <DockerBindInstanceOptions> options = Options.Create(new DockerBindInstanceOptions { BoundBaseDirectory = FullPath, HostBaseDirectory = RemoteDirectory }); ILogger <DockerBindInstanceProvider> logger = new Mock <ILogger <DockerBindInstanceProvider> >().Object; this._instanceProvider = new DockerBindInstanceProvider(options, logger); }
public LocalInstanceProviderTest() : base() { IOptions <LocalInstanceOptions> options = Options.Create(new LocalInstanceOptions { BaseDirectory = FullPath }); ILogger <LocalInstanceProvider> logger = new Mock <ILogger <LocalInstanceProvider> >().Object; this._instanceProvider = new LocalInstanceProvider(options, logger); }
/// <summary> /// Registers an instance provider in the context by the specified name. If an instance provider by the same name already exists, /// then a <see cref="DuplicateInstanceNameException"/> is thrown. /// </summary> /// <param name="name">The name by which the instance provider will be registered in the context.</param> /// <param name="instanceProvider">The instance provider that is registered.</param> public void AddNamedInstanceProvider(RIName name, IInstanceProvider instanceProvider) { if (_instanceProviderDictionary.ContainsKey(name)) { throw new DuplicateInstanceNameException(name); } _instanceProviderDictionary[name] = instanceProvider; }
internal SqlDeserializationContext(IInstanceProvider provider, ISerializationTypeInfoProvider typeInfoProvider) { this.provider = provider; this.typeInfoProvider = typeInfoProvider; stateProvider = provider as IDeserializationStateProvider; if (stateProvider != null) { state = new SortedDictionary<string, object>(StringComparer.Ordinal); stateProvider.BeginDeserialize(state); } }
public void Run(IInstanceProvider instanceProvider, ISolver exactSolver, ISolver solver) { var sizes = new[] { 10, 15, 20, 22, 25 }; foreach (var size in sizes) { RunForSize(instanceProvider, exactSolver, solver, size); Console.WriteLine(); } }
internal DispatchRuntime(System.ServiceModel.Dispatcher.ClientRuntime proxyRuntime, SharedRuntimeState shared) : this(shared) { if (proxyRuntime == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("proxyRuntime"); } this.proxyRuntime = proxyRuntime; this.instanceProvider = new CallbackInstanceProvider(); this.channelDispatcher = new System.ServiceModel.Dispatcher.ChannelDispatcher(shared); this.instanceContextProvider = InstanceContextProviderBase.GetProviderForMode(InstanceContextMode.PerSession, this); }
/// <summary> /// Initializes a new instance of the <see cref="IoCContractBehavior" /> class. /// </summary> /// <param name="instanceProvider"> /// The instance provider. /// </param> /// <exception cref="System.ArgumentNullException"> /// instanceProvider is null. /// </exception> public IoCContractBehavior(IInstanceProvider instanceProvider) { if (instanceProvider == null) { throw new ArgumentNullException(nameof(instanceProvider)); } Contract.EndContractBlock(); _instanceProvider = instanceProvider; }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // Como el constructor es privado, solo se puede invocar a esta interfaz a traves de la propiedad IInstanceProvider istanceProvider = DefaultInstanceProvider.Instance; istanceProvider.register <IUserTaskRepository>(() => new InMemoryUserTaskRepository(prv_populateUserTask())); }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { object[] args = new[] { serviceDescription.ServiceType }; IInstanceProvider provider = Context.Factory().Create <FactoryInstanceProvider>(args); serviceHostBase .ChannelDispatchers .OfType <ChannelDispatcher>() .SelectMany(item => item.Endpoints) .ForEach(item => item.DispatchRuntime.InstanceProvider = provider); }
public static IContractInvoker Use( this IBoltRouteHandler bolt, Type contract, IInstanceProvider instanceProvider, Action <ConfigureContractContext> configure = null, ServerRuntimeConfiguration configuration = null) { if (contract == null) { throw new ArgumentNullException(nameof(contract)); } if (bolt == null) { throw new ArgumentNullException(nameof(bolt)); } if (instanceProvider == null) { throw new ArgumentNullException(nameof(instanceProvider)); } var factory = bolt.ApplicationServices.GetRequiredService <IContractInvokerFactory>(); configuration = configuration ?? new ServerRuntimeConfiguration(bolt.Configuration); IContractInvoker invoker = factory.Create(BoltFramework.GetContract(contract), instanceProvider, configuration); IPipeline <ServerActionContext> pipeline = null; if (configure != null) { ConfigureContractContext ctxt = new ConfigureContractContext(invoker, bolt.ApplicationServices); configure.Invoke(ctxt); if (ctxt.Middlewares.Any()) { pipeline = bolt.ApplicationServices.GetRequiredService <IServerPipelineBuilder>().Build(ctxt.Middlewares); } } if (pipeline != null) { invoker.Pipeline = pipeline; } else if (invoker.Pipeline == null) { // build default pipeline invoker.Pipeline = bolt.ApplicationServices.GetRequiredService <IServerPipelineBuilder>().Build(); } bolt.Add(invoker); return(invoker); }
private object GetInstanceAndInit(IInstanceProvider instanceProvider) { object value = null; bool isNew; instanceProvider.GetInstance(out value, out isNew); if (isNew) { InjectInto(value); } return(value); }
public static void Init(IInstanceProvider instanceProvider) { TryDispose(Gameplay); TryDispose(Economy); TryDispose(Utils); TryDispose(Development); Gameplay = new HGameplay(instanceProvider); Economy = new HEconomy(instanceProvider); Utils = new HUtils(instanceProvider); Development = new HDevelopment(instanceProvider); }
internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime) { this.useSession = dispatch.ChannelDispatcher.Session; this.immutableRuntime = immutableRuntime; this.host = (dispatch.ChannelDispatcher == null) ? null : dispatch.ChannelDispatcher.Host; this.initializers = EmptyArray <IInstanceContextInitializer> .ToArray(dispatch.InstanceContextInitializers); this.provider = dispatch.InstanceProvider; this.singleton = dispatch.SingletonInstanceContext; this.transactionAutoCompleteOnSessionClose = dispatch.TransactionAutoCompleteOnSessionClose; this.releaseServiceInstanceOnTransactionComplete = dispatch.ReleaseServiceInstanceOnTransactionComplete; this.isSynchronized = (dispatch.ConcurrencyMode != ConcurrencyMode.Multiple); this.instanceContextProvider = dispatch.InstanceContextProvider; if (this.provider == null) { ConstructorInfo constructor = null; if (dispatch.Type != null) { constructor = InstanceBehavior.GetConstructor(dispatch.Type); } if (this.singleton == null) { if (dispatch.Type != null && (dispatch.Type.IsAbstract || dispatch.Type.IsInterface)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxServiceTypeNotCreatable))); } if (constructor == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxNoDefaultConstructor))); } } if (constructor != null) { if (this.singleton == null || !this.singleton.IsWellKnown) { InvokerUtil util = new InvokerUtil(); CreateInstanceDelegate creator = util.GenerateCreateInstanceDelegate(dispatch.Type, constructor); this.provider = new InstanceProvider(creator); } } } if (this.singleton != null) { this.singleton.Behavior = this; } }
internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime) { this.useSession = dispatch.ChannelDispatcher.Session; this.immutableRuntime = immutableRuntime; this.host = (dispatch.ChannelDispatcher == null) ? null : dispatch.ChannelDispatcher.Host; this.initializers = EmptyArray<IInstanceContextInitializer>.ToArray(dispatch.InstanceContextInitializers); this.provider = dispatch.InstanceProvider; this.singleton = dispatch.SingletonInstanceContext; this.transactionAutoCompleteOnSessionClose = dispatch.TransactionAutoCompleteOnSessionClose; this.releaseServiceInstanceOnTransactionComplete = dispatch.ReleaseServiceInstanceOnTransactionComplete; this.isSynchronized = (dispatch.ConcurrencyMode != ConcurrencyMode.Multiple); this.instanceContextProvider = dispatch.InstanceContextProvider; if (this.provider == null) { ConstructorInfo constructor = null; if (dispatch.Type != null) { constructor = InstanceBehavior.GetConstructor(dispatch.Type); } if (this.singleton == null) { if (dispatch.Type != null && (dispatch.Type.IsAbstract || dispatch.Type.IsInterface)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxServiceTypeNotCreatable))); } if (constructor == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxNoDefaultConstructor))); } } if (constructor != null) { if (this.singleton == null || !this.singleton.IsWellKnown) { InvokerUtil util = new InvokerUtil(); CreateInstanceDelegate creator = util.GenerateCreateInstanceDelegate(dispatch.Type, constructor); this.provider = new InstanceProvider(creator); } } } if (this.singleton != null) { this.singleton.Behavior = this; } }
// METHODS public bool Check(object container, Type typeToInject, IInstanceProvider provider) { string containerNamespace = container.GetType().Namespace; for (int i = 0; i < _namespaceNameList.Length; i++) { string namespaceName = _namespaceNameList[i]; int index = containerNamespace.IndexOf(namespaceName); if (index == 0 && (containerNamespace.Length == namespaceName.Length || containerNamespace[namespaceName.Length] == '.')) { return(true); } } return(false); }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { Type serviceType = serviceDescription.ServiceType; IInstanceProvider instanceProvider = InstanceFabric(serviceType); foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers) { foreach (EndpointDispatcher endpointDispatcher in dispatcher.Endpoints) { DispatchRuntime dispatchRuntime = endpointDispatcher.DispatchRuntime; dispatchRuntime.InstanceProvider = instanceProvider; //dispatchRuntime.InstanceContextInitializers.Add(new UnityInstanceContextInitializer()) } } }
private void RegisterInstanceInternal <TComponent>(IInstanceProvider instance) where TComponent : class { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } var key = _typeIdGenerator.Generate <TComponent>(); SpinUntilSecurityModeIsAvailable(); if (_typeInstancesSafe.Object.ContainsKey(key)) { throw new ArgumentException($"{typeof(TComponent).FullName} is already registered."); } _typeInstancesSafe.ApplyChanges(dic => { dic.Add(key, instance); }); }
public IContractInvoker Create(Type contract, IInstanceProvider instanceProvider) { if (contract == null) { throw new ArgumentNullException(nameof(contract)); } if (instanceProvider == null) { throw new ArgumentNullException(nameof(instanceProvider)); } ContractInvoker invoker = new ContractInvoker{ Contract = contract, InstanceProvider = instanceProvider }; return invoker; }
/// <summary> /// Initializes a new instance of the <see cref="ContractBehavior"/> class. /// </summary> /// <param name="instanceProvider">The instance provider.</param> /// <exception cref="ArgumentNullException">The <paramref name="instanceProvider"/> is <c>null</c>.</exception> public ContractBehavior(IInstanceProvider instanceProvider) { Argument.IsNotNull("instanceProvider", instanceProvider); _instanceProvider = instanceProvider; }
/// <summary> /// Initializes a new instance of the <see cref="FactoryInterceptor"/> class. /// </summary> /// <param name="resolutionRoot">The resolution root used to create new instances for the factory.</param> /// <param name="instanceProvider">The instance provider.</param> public FactoryInterceptor(IResolutionRoot resolutionRoot, IInstanceProvider instanceProvider) : base(resolutionRoot) { this.instanceProvider = instanceProvider; }
public ComposedServiceBehavior(Type serviceType, IServiceLocator serviceLocator) { _instanceProvider = new ComposedInstanceProvider(serviceType, serviceLocator); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceLocationContractBehavior"/> class. /// </summary> /// <param name="instanceProvider">The instance provider.</param> public ServiceLocationContractBehavior(IInstanceProvider instanceProvider) { if (instanceProvider == null) throw new ArgumentNullException("instanceProvider"); _instanceProvider = instanceProvider; }
protected override IInstanceProvider<IJavaScriptCompiler> CreateCompilerProvider( IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider) { return new InstanceProvider<IJavaScriptCompiler>( () => new UglifyCompiler(jsRuntimeProvider)); }
public WindsorContainerResolver(ContainerSpecification containerSpecification) { _containerSpecification = containerSpecification; _windsorContainer = new WindsorContainer(); _instanceProvider = new WindsorContainerProvider(_windsorContainer); }
/// <summary> /// /// </summary> /// <param name="provider"></param> /// <param name="type"></param> public TypeFactory(IInstanceProvider provider, Type type) : base(provider) { this.type = type; }
protected abstract IInstanceProvider<IJavaScriptCompiler> CreateCompilerProvider( IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider);
public InstanceProviderBehavior(IInstanceProvider instanceProvider) { this.instanceProvider = instanceProvider; }
protected Factory(IInstanceProvider provider) { Provider = provider; }
internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime) { _provider = dispatch.InstanceProvider; _instanceContextProvider = dispatch.InstanceContextProvider; }
public virtual IInstanceProvider GetInstanceProvider(Type serviceType, IInstanceProvider defaultInstanceProvider) { return new InstanceProvider(ObjectFactory.Container, serviceType); }
public JavaScriptCompilerContentTransformBase() { _jsRuntimeProvider = new InstanceProvider<IJavaScriptRuntime>( () => new IEJavaScriptRuntime()); _jsCompilerProvider = CreateCompilerProvider(_jsRuntimeProvider); }
public virtual IInstanceProvider GetInstanceProvider(Type serviceType, IInstanceProvider defaultInstanceProvider) { return defaultInstanceProvider; }
public UnityServiceBehavior(IInstanceProvider instanceProvider) { _instanceProvider = instanceProvider; }
public JavaScriptCompilerBase(IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider) { _jsRuntimeProvider = jsRuntimeProvider; }
public CoffeeScriptCompiler(IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider) : base(jsRuntimeProvider) { }
public CoffeeToJs() { runtimeProvider = new InstanceProvider<IJavaScriptRuntime>(() => (IJavaScriptRuntime)new IEJavaScriptRuntime()); compilerProvider = CreateCompilerProvider(runtimeProvider); }
private static IInstanceProvider<IJavaScriptCompiler> CreateCompilerProvider(IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider) { return new InstanceProvider<IJavaScriptCompiler>(() => (IJavaScriptCompiler)new CoffeeScriptCompiler(jsRuntimeProvider)); }
public UglifyCompiler(IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider) : base(jsRuntimeProvider) { }