public InstanceProviderFactory(
            IInstanceProvider instanceProvider)
        {
            Requires.NotNull(instanceProvider, nameof(instanceProvider));

            this.instanceProvider = instanceProvider;
        }
Ejemplo n.º 2
0
 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;
        }
Ejemplo n.º 4
0
 public HUtils(IInstanceProvider instanceProvider)
 {
     configService      = instanceProvider.GetInstance <IConfigService>();
     fullscreenAdsModel = instanceProvider.GetInstance <IFullscreenAdsModel>();
     lifetimeStatistics = instanceProvider.GetInstance <ILifetimeStatistics>();
     showCustomAdSignal = instanceProvider.GetInstance <ShowCustomAdSignal>();
 }
Ejemplo n.º 5
0
 /// <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;
 }
Ejemplo n.º 6
0
 public ServiceHost(Uri uri, IInstanceProvider instanceProvider) : base(typeof(TImpl), uri)
 {
     foreach (var contract in ImplementedContracts)
     {
         contract.Value.ContractBehaviors.Add(new InstanceProviderBehaviour(instanceProvider));
     }
 }
Ejemplo n.º 7
0
        public Pool(
            IInstanceProvider instanceProvider)
        {
            Requires.NotNull(instanceProvider, nameof(instanceProvider));

            this.instanceProvider = instanceProvider;
        }
Ejemplo n.º 8
0
        public CompareRunner(IInstanceProvider instanceProvider, ISolver exactSolver, ISolver solver)
        {
            this.exactSolver = exactSolver;
            this.solver      = solver;

            instances = instanceProvider.GetInstances();
        }
Ejemplo n.º 9
0
        // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

        public CmdLineExecutor(ClassDefinition classDefinition, IInstanceProvider instanceProvider)
        {
            Defintion        = classDefinition ?? throw new ArgumentNullException(nameof(classDefinition));
            InstanceProvider = instanceProvider;
            Type             = instanceProvider.TypeOf;
            Instance         = instanceProvider.Instance;
        }
Ejemplo n.º 10
0
 public void Init(ResourceManager rm, IInstanceProvider instanceProvider, InstantiationParameters instantiationParams, AsyncOperationHandle <GameObject> dependency)
 {
     m_RM                  = rm;
     m_dependency          = dependency;
     m_instanceProvider    = instanceProvider;
     m_instantiationParams = instantiationParams;
 }
Ejemplo n.º 11
0
        public InstanceProviderSingleton(
            IInstanceProvider instanceProvider)
        {
            Requires.NotNull(instanceProvider, nameof(instanceProvider));

            this.instanceProvider = instanceProvider;
        }
Ejemplo n.º 12
0
 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;
 }
Ejemplo n.º 14
0
 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;
        }
Ejemplo n.º 16
0
        public UnityContractBehavior(IInstanceProvider instanceProvider)
        {
            if (instanceProvider == null)
            {
                throw new ArgumentNullException("instanceProvider");
            }

            _instanceProvider = instanceProvider;
        }
Ejemplo n.º 17
0
 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);
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        /// <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);
     }
 }
Ejemplo n.º 22
0
        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();
            }
        }
Ejemplo n.º 23
0
 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);
 }
Ejemplo n.º 24
0
        /// <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;
        }
Ejemplo n.º 25
0
        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()));
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        private object GetInstanceAndInit(IInstanceProvider instanceProvider)
        {
            object value = null;
            bool   isNew;

            instanceProvider.GetInstance(out value, out isNew);
            if (isNew)
            {
                InjectInto(value);
            }
            return(value);
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
        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;
            }
        }
Ejemplo n.º 31
0
        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;
            }
        }
Ejemplo n.º 32
0
        //  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);
        }
Ejemplo n.º 33
0
        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())
                }
            }
        }
Ejemplo n.º 34
0
        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); });
        }
Ejemplo n.º 35
0
        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;
        }
Ejemplo n.º 36
0
        /// <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;
 }
Ejemplo n.º 38
0
 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);
 }
Ejemplo n.º 42
0
 /// <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);
Ejemplo n.º 44
0
 public InstanceProviderBehavior(IInstanceProvider instanceProvider)
 {
     this.instanceProvider = instanceProvider;
 }
Ejemplo n.º 45
0
 protected Factory(IInstanceProvider provider)
 {
     Provider = provider;
 }
Ejemplo n.º 46
0
 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;
 }
Ejemplo n.º 50
0
 public UnityServiceBehavior(IInstanceProvider instanceProvider)
 {
     _instanceProvider = instanceProvider;
 }
 public JavaScriptCompilerBase(IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider)
 {
     _jsRuntimeProvider = jsRuntimeProvider;
 }
 public CoffeeScriptCompiler(IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider)
     : base(jsRuntimeProvider)
 {
 }
Ejemplo n.º 53
0
 public CoffeeToJs()
 {
     runtimeProvider = new InstanceProvider<IJavaScriptRuntime>(() => (IJavaScriptRuntime)new IEJavaScriptRuntime());
     compilerProvider = CreateCompilerProvider(runtimeProvider);
 }
Ejemplo n.º 54
0
 private static IInstanceProvider<IJavaScriptCompiler> CreateCompilerProvider(IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider)
 {
     return new InstanceProvider<IJavaScriptCompiler>(() => (IJavaScriptCompiler)new CoffeeScriptCompiler(jsRuntimeProvider));
 }
Ejemplo n.º 55
0
 public UglifyCompiler(IInstanceProvider<IJavaScriptRuntime> jsRuntimeProvider)
     : base(jsRuntimeProvider)
 {
 }