コード例 #1
0
		public virtual void Inizialize()
		{
			container = CreateDependencyContainer();

			container.Singleton(fooValidator);
			container.Singleton<IFooService, FooService>();
		}
コード例 #2
0
 public void Initialize(IDependencyContainer container)
 {
     container
         .RegisterType<IMethods,Managercs>()
         .RegisterType<IRedisConnectorFactory, RedisConnectorFactory>()
         ;
 }
コード例 #3
0
        public void Bootstrap(IDependencyContainer container)
        {
            // Framework "er"s
            container.RegisterSingleton<IHttpRequestHandler, HttpRequestHandler>();
            container.RegisterSingleton<IJsonSerializer, NewtonsoftJsonSerializer>();
            container.RegisterSingleton<IRouteResolver, RouteResolver>();
            container.RegisterSingleton<IParameterResolver, ParameterResolver>();
            container.RegisterSingleton<IActionInvoker, ActionInvoker>();
            container.RegisterSingleton<IOwinHandler, GenericOwinHandler>();
            container.RegisterSingleton<IServiceConfigBuilder, ServiceConfigBuilder>();
            container.RegisterSingleton<ILogger, SimpleLogger>();

            // Database
            container.RegisterTransient<IUnitOfWork, UnitOfWork>();
            container.RegisterSingleton<IUnitOfWorkStack, UnitOfWorkStack>();
            container.RegisterSingleton<IRepository, Repository>();

            // Interceptors
            container.RegisterSingleton<IActionInterceptorBuilder, MonospadActionInterceptorBuilder>();

            // Providers
            container.RegisterSingleton<IAuthProvider, AuthProvider>();
            container.RegisterSingleton<ICryptoProvider, CryptoProvider>();
            container.RegisterSingleton<IMailProvider, MailProvider>();
            container.RegisterSingleton<IServiceRouteProvider, MonospadRouteProvider>();

            // Auth
            container.RegisterSingleton<IUserService, UserService>();
            container.RegisterSingleton<INoteService, NoteService>();
        }
コード例 #4
0
ファイル: FrameworkConfig.cs プロジェクト: LazyTarget/Lux
        public override void Configure(XElement element)
        {
            XElement elem;
            if (element == null)
                throw new ArgumentNullException(nameof(element));

            elem = FindElement(element, nameof(CultureInfo));
            if (elem != null)
            {
                var name = elem.GetAttributeValue("value") ?? elem.Value;
                CultureInfo = CultureInfo.GetCultureInfo(name);
            }

            elem = FindElement(element, nameof(DependencyContainer));
            if (elem != null)
            {
                var typeStr = elem.GetAttributeValue("type");
                var type = Type.GetType(typeStr, true);
                if (!typeof (IDependencyContainer).IsAssignableFrom(type))
                    throw new InvalidCastException("Invalid type");

                object obj;
                if (Framework.TypeInstantiator != null)
                    obj = Framework.TypeInstantiator.Instantiate(type);
                else
                    obj = Activator.CreateInstance(type);

                var instance = (IDependencyContainer) obj;
                DependencyContainer = instance;
            }
        }
コード例 #5
0
        public async Task Startup(ServiceLocatorProvider locatorProvider,
            IDependencyContainer container,
            Action<IDependencyContainer> buildDependencies = null)
        {
            await CommenceStartup();

            //            var builder = new ContainerBuilder();

            using (container.StartUpdate())
            {
                // Build and application dependencies
                RegisterDependencies(container);

                buildDependencies?.Invoke(container);

                //// Perform registrations and build the container.
                //var container = builder.Build();

                await BuildCoreDependencies(container);
            }

            // Set the service locator to an AutofacServiceLocator.
            //var csl = new AutofacServiceLocator(container);
            //ServiceLocator.SetLocatorProvider(() => csl);
            ServiceLocator.SetLocatorProvider(locatorProvider);

            await CompleteStartup();
        }
コード例 #6
0
 void IApplicationHost.InitializeContainer(IDependencyContainer container)
 {
     container
         .Register<IHttpConnector, HttpConnector>(() => new HttpConnector())
         .Register<IHttpFileHandler, WebClientHttpFileHandler>(() => new WebClientHttpFileHandler())
         ;
 }
コード例 #7
0
 protected override void InitializeContainer(IDependencyContainer container)
 {
     // Add default winrt registration
     base.InitializeContainer(container);
     // Add aspnet specific registrations
     container.Register<IUserContext, AspnetUserContext>(() => UserContextViaHttpContext.Instance);
 }
コード例 #8
0
        /// <summary>
        /// Determines which constructor implementation should be used from a given <see cref="IDependencyContainer"/> instance.
        /// </summary>
        /// <param name="targetType">The target type that contains list of constructors to be resolved.</param>
        /// <param name="container">The dependency container that holds the current set of dependencies.</param>
        /// <returns>An implementation that can instantiate the object associated with the constructor.</returns>
        public virtual IImplementation<ConstructorInfo> ResolveFrom(System.Type targetType, IDependencyContainer container)
        {
            IImplementation<ConstructorInfo> result = null;

            var constructors = new List<IImplementation<ConstructorInfo>>();
            foreach(var constructor in targetType.GetConstructors())
            {
                var constructorCall = CreateConstructorCall(constructor);
                constructors.Add(constructorCall);
            }

            var bestParameterCount = 0;
            foreach (var constructor in constructors)
            {
                var missingDependencies = constructor.GetMissingDependencies(container);
                var missingItems = new List<IDependency>(missingDependencies);
                var hasMissingDependencies = missingDependencies == null || missingItems.Count > 0;
                if (hasMissingDependencies)
                    continue;

                var targetConstructor = constructor.Target;
                var parameters = targetConstructor.GetParameters();
                var parameterCount = parameters.Length;

                if (result == null || parameterCount > bestParameterCount)
                {
                    result = constructor;
                    bestParameterCount = parameterCount;
                }
            }

            return result;
        }
コード例 #9
0
 public static void Instalize()
 {
     Container = new DependencyContainer();
     Container.RegisterType<CarPerformanceSimulator>().As<ICarPerformanceSimulator>();
     Container.RegisterType<RaceFactory>().As<IRaceFactory>();
     Container.RegisterType<CarFactory>().As<ICarFactory>();
     Container.RegisterType<DistanceCalculator>().As<IDistanceCalculator>();
 }
コード例 #10
0
 public virtual void InitializeContainer(IDependencyContainer container)
 {
     container
         .Register<IHttpConnector, HttpConnector>(() => HttpConnector.Instance)
         .Register<IHttpFileHandler, WebClientHttpFileHandler>(() => new WebClientHttpFileHandler())
         .Register<ITraceWriter, DefaultTraceWriter>(() => DefaultTraceWriter.Instance)
         ;
 }
コード例 #11
0
 public static void ConfigureContainer(IDependencyContainer container)
 {
     container
             .Register<IJsonSerializer, JsonDotNetSerializer>(() => new JsonDotNetSerializer())
             .Register<ITraceWriter, NullTraceWriter>(() => NullTraceWriter.Instance)
             .RegisterInstance<Services.ICreateInstanceBehaviorFactory, Services.CreateInstanceBehaviorFactory>(new Services.CreateInstanceBehaviorFactory())
             ;
 }
コード例 #12
0
        public App(IDependencyContainer container)
            : this()
        {
            RegisterViews();

            // Setup the navigation service and navigate to first page
            SetupNavigationService(container).NavigateTo<BeaconsViewModel>();
        }
コード例 #13
0
 public override void RegisterDependencies(IDependencyContainer container)
 {
     base.RegisterDependencies(container);
     foreach (var stateGroup in StateManager.StateGroups)
     {
         (stateGroup.Value as IRegisterDependencies)?.RegisterDependencies(container);
     }
 }
コード例 #14
0
 public void InitializeContainer(IDependencyContainer container)
 {
     
     container
         .Register <IRealTimeTransport, SignalRTransport>( () => new SignalRTransport() )
         .Register<IHttpConnector, HttpConnector>(() => new HttpConnector())
         .Register<IHttpFileHandler, WebClientHttpFileHandler>(() => new WebClientHttpFileHandler())
         .Register<IExceptionFactory, ExceptionFactory>(() => new ExceptionFactory());
 }
コード例 #15
0
 /// <summary>
 /// 
 /// </summary>
 public virtual void RegisterDependencies(IDependencyContainer container)
 {
     var hasSM = this as IHasStates;
     if (hasSM == null) return;
     foreach (var stateGroup in hasSM.StateManager.StateGroups)
     {
         (stateGroup.Value as IRegisterDependencies)?.RegisterDependencies(container);
     }
 }
コード例 #16
0
        /// <summary>
        /// Bootstraps dependencies
        /// </summary>
        /// <param name="dependencyContainer"></param>
        public virtual void Bootstrap(IDependencyContainer dependencyContainer)
        {
            dependencyContainer.RegisterTransient<IUnitOfWork, EFUnitOfWork>();
            dependencyContainer.RegisterTransient<IRepository, EFRepository>();
            dependencyContainer.RegisterTransient<DbContext, ProjectTemplateContext>();

            dependencyContainer.RegisterTransient<IServiceBase<Film>, ServiceBase<Film>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Film>, RepositoryBase<Film>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Film>, BusinessBase<Film>>();
            dependencyContainer.RegisterTransient<IServiceFilm, ServiceFilm>();
            dependencyContainer.RegisterTransient<IRepositoryFilm, RepositoryFilm>();
            dependencyContainer.RegisterTransient<IBusinessFilm, BusinessFilm>();

            dependencyContainer.RegisterTransient<IServiceBase<Actor>, ServiceBase<Actor>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Actor>, RepositoryBase<Actor>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Actor>, BusinessBase<Actor>>();
            dependencyContainer.RegisterTransient<IServiceActor, ServiceActor>();
            dependencyContainer.RegisterTransient<IRepositoryActor, RepositoryActor>();
            dependencyContainer.RegisterTransient<IBusinessActor, BusinessActor>();

            dependencyContainer.RegisterTransient<IServiceBase<Director>, ServiceBase<Director>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Director>, RepositoryBase<Director>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Director>, BusinessBase<Director>>();
            dependencyContainer.RegisterTransient<IServiceDirector, ServiceDirector>();
            dependencyContainer.RegisterTransient<IRepositoryDirector, RepositoryDirector>();
            dependencyContainer.RegisterTransient<IBusinessDirector, BusinessDirector>();

            dependencyContainer.RegisterTransient<IServiceBase<FilmType>, ServiceBase<FilmType>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<FilmType>, RepositoryBase<FilmType>>();
            dependencyContainer.RegisterTransient<IBusinessBase<FilmType>, BusinessBase<FilmType>>();
            dependencyContainer.RegisterTransient<IServiceFilmType, ServiceFilmType>();
            dependencyContainer.RegisterTransient<IRepositoryFilmType, RepositoryFilmType>();
            dependencyContainer.RegisterTransient<IBusinessFilmType, BusinessFilmType>();

            dependencyContainer.RegisterTransient<IServiceBase<Producer>, ServiceBase<Producer>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Producer>, RepositoryBase<Producer>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Producer>, BusinessBase<Producer>>();
            dependencyContainer.RegisterTransient<IServiceProducer, ServiceProducer>();
            dependencyContainer.RegisterTransient<IRepositoryProducer, RepositoryProducer>();
            dependencyContainer.RegisterTransient<IBusinessProducer, BusinessProducer>();

            dependencyContainer.RegisterTransient<IServiceBase<User>, ServiceBase<User>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<User>, RepositoryBase<User>>();
            dependencyContainer.RegisterTransient<IBusinessBase<User>, BusinessBase<User>>();
            dependencyContainer.RegisterTransient<IServiceUser, ServiceUser>();
            dependencyContainer.RegisterTransient<IRepositoryUser, RepositoryUser>();
            dependencyContainer.RegisterTransient<IBusinessUser, BusinessUser>();

            dependencyContainer.RegisterTransient<IServiceBase<Writer>, ServiceBase<Writer>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Writer>, RepositoryBase<Writer>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Writer>, BusinessBase<Writer>>();
            dependencyContainer.RegisterTransient<IServiceWriter, ServiceWriter>();
            dependencyContainer.RegisterTransient<IRepositoryWriter, RepositoryWriter>();
            dependencyContainer.RegisterTransient<IBusinessWriter, BusinessWriter>();
        }
コード例 #17
0
 private static void RegisterDefaults(IDependencyContainer dependencyContainer)
 {
     dependencyContainer
                     .Register<IUserContext, StaticUserContext>(() => new StaticUserContext())
                     .Register<IJsonSerializer, JsonDotNetSerializer>(() => new JsonDotNetSerializer())
                     .Register<IFileService, FileService>(() => FileService.Instance)
                     .Register<IConnectionService, ConnectionService>(() => ConnectionService.Instance)
                     .Register<ISessionService, SessionService>(() => SessionService.Instance)
                     .Register<IArticleService, ArticleService>(() => ArticleService.Instance)
                     .Register<IUserService, UserService>(() => UserService.Instance)
                     ;
 }
コード例 #18
0
        private NavigationService SetupNavigationService(IDependencyContainer container)
        {
            var baseNavigationPage = new NavigationPage();

            var navigation = baseNavigationPage.Navigation;
            container.Register(navigation);

            var navigationService = new NavigationService(navigation);
            container.Register<INavigationService>(navigationService);

            MainPage = baseNavigationPage;
            return navigationService;
        }
コード例 #19
0
		public void Configure(IDependencyContainer container) {
			container.Register<IEventPublisher, EventPublisher>();
			container.Register<IEventListener, AsyncTestEventListener>();
			AConf aSyncConf = new AConf();
			aSyncConf.EndPoint = () => {
				return "async/execute";
			};
			aSyncConf.SiteUrl = () => {
				return ConfigurationManager.AppSettings["SiteURL"];
			};
			container.RegisterSingleton<IAsyncConfiguration>(aSyncConf);
			container.Register<IAsyncTask, AsyncWebTask>();
		}
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericInstanceContainer"/> class.
        /// </summary>
        /// <param name="serviceName">The name of the generic service.</param>
        /// <param name="genericServiceType">The generic type that represents the service type.</param>
        /// <param name="genericTypeImplementation">The type that represents the generic service type implementation.</param>
        /// <param name="dependencyContainer">The dependency map that describes the list of services that will be available to the instantiated generic types.</param>
        public GenericInstanceContainer(string serviceName, Type genericServiceType, Type genericTypeImplementation, IDependencyContainer dependencyContainer)
        {
            if (!genericServiceType.IsGenericTypeDefinition)
                throw new ArgumentException("The type must be a generic type definition", "genericServiceType");

            if (!genericTypeImplementation.IsGenericTypeDefinition)
                throw new ArgumentException("The type must be a generic type definition", "genericTypeImplementation");

            _serviceName = serviceName;
            _genericServiceType = genericServiceType;
            _genericTypeImplementation = genericTypeImplementation;
            _dependencyContainer = dependencyContainer;
        }
コード例 #21
0
ファイル: IdentityBuilder.cs プロジェクト: suku2356/Project
        public virtual void Configure(IDependencyContainer container)
        {
            Database.SetInitializer<IdentityDbContext>(null);

            container.RegisterPerRequest<IContext, Context>();
            container.RegisterPerRequest<DbContext, IdentityDbContext>(new Dictionary<String, Object> { { "nameOrConnectionString", ConfigurationManager.ConnectionStrings["mvcForum.DataProvider.MainDB"].ConnectionString } });

            container.RegisterGeneric(typeof(IRepository<>), typeof(Repository<>));

            // TODO: Do this in some other way!!
            new SpecificRepositoryConfiguration().Configure(container);

            //container.RegisterGenericPerRequest(typeof(IUserStore<ApplicationUser>), typeof(UserStore<ApplicationUser>));
            //container.RegisterGenericPerRequest(typeof(UserManager<ApplicationUser>), typeof(UserManager<ApplicationUser>));
            //container.RegisterGenericPerRequest(typeof(RoleManager<IdentityRole>), typeof(RoleManager<IdentityRole>));
        }
コード例 #22
0
 public void InitializeContainer(IDependencyContainer container)
 {
     container
         .Register<IHttpConnector, HttpConnector>(() => new HttpConnector())
         .Register<IHttpFileHandler, WebClientHttpFileHandler>(() => new WebClientHttpFileHandler())
         .RegisterInstance<ILocalStorage, IsolatedLocalStorage>("wp8", IsolatedLocalStorage.Instance)
         .RegisterInstance<ITraceWriter, DebugTraceWriter>(new DebugTraceWriter());
         ;
     var deviceState = new WPDeviceState(
         container.Build<ILocalStorage>("wp8"),
         container.Build<IJsonSerializer>());
     container.RegisterInstance<IDeviceState, WPDeviceState>("wp8", deviceState);
     var appState = new WPApplicationState(
         container.Build<ILocalStorage>("wp8"),
         container.Build<IJsonSerializer>());
     container.RegisterInstance<IApplicationState, WPApplicationState>("wp8", appState);
 }
コード例 #23
0
        /// <summary>
        /// Compiles a dependency graph into an IOC container.
        /// </summary>
        /// <param name="dependencyContainer">The <see cref="IDependencyContainer"/> instance that contains the services that will be instantiated by compiled container.</param>
        /// <returns>An assembly containing the compiled IOC container.</returns>
        public AssemblyDefinition Compile(string typeName, string namespaceName, string assemblyName, IDependencyContainer dependencyContainer)
        {
            var hash = dependencyContainer.GetHashCode();

            AssemblyDefinition result;
            lock (_cache)
            {
                if (_cache.ContainsKey(hash))
                    return _cache[hash];

                // Cache the result
                result = _compiler.Compile("MicroContainer", "Hiro.Containers", "Hiro.CompiledContainers", dependencyContainer);

                _cache[hash] = result;
            }

            return result;
        }
コード例 #24
0
        /// <summary>
        /// Bootstraps dependencies
        /// </summary>
        /// <param name="dependencyContainer"></param>
        public virtual void Bootstrap(IDependencyContainer dependencyContainer)
        {
            dependencyContainer.RegisterTransient<IUnitOfWork, EFUnitOfWork>();
            dependencyContainer.RegisterTransient<IRepository, EFRepository>();
            dependencyContainer.RegisterTransient<DbContext, ProjectTemplateContext>();

            dependencyContainer.RegisterTransient<IServiceBase<Student>, ServiceBase<Student>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Student>, RepositoryBase<Student>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Student>, BusinessBase<Student>>();

            dependencyContainer.RegisterTransient<IServiceStudent, ServiceStudent>();
            dependencyContainer.RegisterTransient<IRepositoryStudent, RepositoryStudent>();
            dependencyContainer.RegisterTransient<IBusinessStudent, BusinessStudent>();

            dependencyContainer.RegisterTransient<IServiceBase<Firm>, ServiceBase<Firm>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Firm>, RepositoryBase<Firm>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Firm>, BusinessBase<Firm>>();
            dependencyContainer.RegisterTransient<IServiceFirm, ServiceFirm>();
            dependencyContainer.RegisterTransient<IRepositoryFirm, RepositoryFirm>();
            dependencyContainer.RegisterTransient<IBusinessFirm, BusinessFirm>();

            dependencyContainer.RegisterTransient<IServiceBase<User>, ServiceBase<User>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<User>, RepositoryBase<User>>();
            dependencyContainer.RegisterTransient<IBusinessBase<User>, BusinessBase<User>>();
            dependencyContainer.RegisterTransient<IServiceUser, ServiceUser>();
            dependencyContainer.RegisterTransient<IRepositoryUser, RepositoryUser>();
            dependencyContainer.RegisterTransient<IBusinessUser, BusinessUser>();

            dependencyContainer.RegisterTransient<IServiceBase<Actor>, ServiceBase<Actor>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Actor>, RepositoryBase<Actor>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Actor>, BusinessBase<Actor>>();
            dependencyContainer.RegisterTransient<IServiceActor, ServiceActor>();
            dependencyContainer.RegisterTransient<IRepositoryActor, RepositoryActor>();
            dependencyContainer.RegisterTransient<IBusinessActor, BusinessActor>();

            dependencyContainer.RegisterTransient<IServiceBase<Director>, ServiceBase<Director>>();
            dependencyContainer.RegisterTransient<IRepositoryBase<Director>, RepositoryBase<Director>>();
            dependencyContainer.RegisterTransient<IBusinessBase<Director>, BusinessBase<Director>>();
            dependencyContainer.RegisterTransient<IServiceDirector, ServiceDirector>();
            dependencyContainer.RegisterTransient<IRepositoryDirector, RepositoryDirector>();
            dependencyContainer.RegisterTransient<IBusinessDirector, BusinessDirector>();
        }
コード例 #25
0
        /// <summary>
        /// Gets the list of available services from the given dependency container.
        /// </summary>
        /// <param name="dependencyContainer">The container that holds the application dependencies.</param>
        /// <returns>The service map.</returns>
        public IDictionary<IDependency, IImplementation> GetAvailableServices(IDependencyContainer dependencyContainer)
        {
            var serviceMap = new Dictionary<IDependency, IImplementation>();

            var dependencies = dependencyContainer.Dependencies;
            foreach (var dependency in dependencies)
            {
                var implementations = dependencyContainer.GetImplementations(dependency, false);

                var concreteTypes = new List<IImplementation>(implementations);

                var implementation = concreteTypes.Count > 0 ? concreteTypes[0] : null;
                if (implementation == null)
                    continue;

                serviceMap[dependency] = implementation;
            }

            return serviceMap;
        }
コード例 #26
0
 private static void RegisterDefaults(IDependencyContainer dependencyContainer)
 {
     dependencyContainer
             .Register<ISubscriptionManager, SingletonSubscriptionManager>( () => SingletonSubscriptionManager.Instance )
             .Register<IRealTimeChannelFactory, RealTimeChannelFactory>( () => new RealTimeChannelFactory() )
             .Register<IRealTimeChannel, RealTimeChannel>(  () => new RealTimeChannel() )
             .Register<IUserContext, StaticUserContext>(() => new StaticUserContext())
             .Register<IJsonSerializer, JsonDotNetSerializer>(() => new JsonDotNetSerializer())
             .Register<IExceptionFactory, ServiceExceptionFactory>( () => ServiceExceptionFactory.Instance )
             .Register<ITraceWriter, NullTraceWriter>(() => NullTraceWriter.Instance)
             ;
 }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the mwo.SimpleDI.DependencyContainer class.
 /// </summary>
 /// <param name="parentContainer">A container to be set as the parent. Is considered when resolving.</param>
 public DependencyContainer(IDependencyContainer parentContainer) : this()
 {
     ParentContainer = parentContainer;
 }
コード例 #28
0
 /// <summary>
 /// Sets <paramref name="container"/> as a container to be used by LightBDD scenarios and steps.
 /// </summary>
 /// <param name="container">Container to use.</param>
 /// <returns>Self.</returns>
 public DependencyContainerConfiguration UseContainer(IDependencyContainer container)
 {
     ThrowIfSealed();
     DependencyContainer = container;
     return(this);
 }
 /// <summary>
 /// Registers an instance along with all of its implemented interfaces to the resource container.
 /// </summary>
 /// <param name="container">The container with resources.</param>
 /// <param name="instance">Instance resource to bind to the container.</param>
 /// <typeparam name="T">Type of the instance being bound.</typeparam>
 public static void RegisterInstanceWithInterfaces <T>(this IDependencyContainer container, T instance)
 {
     container.ThrowIfNull(nameof(container));
     container.RegisterWithInterfaces <T>(new InstanceBinding <T>(instance));
 }
コード例 #30
0
 public FileLogger(IDependencyContainer container) : base(container)
 {
 }
コード例 #31
0
 public void Shutdown(IDependencyContainer container)
 {
     container.Resolve <IF_IContentPluginLoader>().Shutdown();
     container.Unbind <IF_IContentPluginLoader>();
 }
コード例 #32
0
 public void Initialize(IDependencyContainer dependencyContainer)
 {
     dependencyContainer.Resolve <Main>().
     StartCoroutine(dependencyContainer.Resolve <ServerCommunications>().GetRequest(_getUrl));
 }
コード例 #33
0
 public WrappingDependencyContainer(IDependencyContainer v1)
 {
     _v1 = v1;
 }
コード例 #34
0
    /// <summary>
    /// Transfers <see cref="Dependency"/>s from one <see cref="IDependencyContainer"/> to another.
    /// </summary>
    /// <param name="target">The <see cref="IDependencyContainer"/> to add the <see cref="Dependency"/>s to.</param>
    /// <param name="requirements">The requirements which restrict which <see cref="Dependency"/>s are applicable.</param>
    /// <param name="from">The <see cref="IDependencyContainer"/> to get the <see cref="Dependency"/>s to.</param>
    public static void AddDependencies(this IDependencyContainer target, Requirements requirements, IDependencyContainer from)
    {
        #region Sanity checks
        if (target == null)
        {
            throw new ArgumentNullException(nameof(target));
        }
        if (requirements == null)
        {
            throw new ArgumentNullException(nameof(requirements));
        }
        if (from == null)
        {
            throw new ArgumentNullException(nameof(from));
        }
        #endregion

        target.Dependencies.AddRange(from.Dependencies.Where(x => x.IsApplicable(requirements)).CloneElements());
        target.Restrictions.AddRange(from.Restrictions.Where(x => x.IsApplicable(requirements)).CloneElements());
    }
コード例 #35
0
        /// <summary>
        /// Bootstraps dependencies
        /// </summary>
        /// <param name="dependencyContainer"></param>
        public virtual void Bootstrap(IDependencyContainer dependencyContainer)
        {
            dependencyContainer.RegisterTransient <IUnitOfWork, EFUnitOfWork>();
            dependencyContainer.RegisterTransient <IRepository, EFRepository>();
            dependencyContainer.RegisterTransient <DbContext, ProjectTemplateContext>();

            dependencyContainer.RegisterTransient <IServiceBase <JobInterview>, ServiceBase <JobInterview> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <JobInterview>, RepositoryBase <JobInterview> >();
            dependencyContainer.RegisterTransient <IBusinessBase <JobInterview>, BusinessBase <JobInterview> >();
            dependencyContainer.RegisterTransient <IServiceJobInterview, ServiceJobInterview>();
            dependencyContainer.RegisterTransient <IRepositoryJobInterview, RepositoryJobInterview>();
            dependencyContainer.RegisterTransient <IBusinessJobInterview, BusinessJobInterview>();

            dependencyContainer.RegisterTransient <IServiceBase <Firm>, ServiceBase <Firm> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <Firm>, RepositoryBase <Firm> >();
            dependencyContainer.RegisterTransient <IBusinessBase <Firm>, BusinessBase <Firm> >();
            dependencyContainer.RegisterTransient <IServiceFirm, ServiceFirm>();
            dependencyContainer.RegisterTransient <IRepositoryFirm, RepositoryFirm>();
            dependencyContainer.RegisterTransient <IBusinessFirm, BusinessFirm>();

            dependencyContainer.RegisterTransient <IServiceBase <EmploymentStatus>, ServiceBase <EmploymentStatus> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <EmploymentStatus>, RepositoryBase <EmploymentStatus> >();
            dependencyContainer.RegisterTransient <IBusinessBase <EmploymentStatus>, BusinessBase <EmploymentStatus> >();
            dependencyContainer.RegisterTransient <IServiceEmploymentStatus, ServiceState>();
            dependencyContainer.RegisterTransient <IRepositoryEmploymentStatus, RepositoryEmploymentStatus>();
            dependencyContainer.RegisterTransient <IBusinessEmploymentStatus, BusinessState>();

            dependencyContainer.RegisterTransient <IServiceBase <Trainee>, ServiceBase <Trainee> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <Trainee>, RepositoryBase <Trainee> >();
            dependencyContainer.RegisterTransient <IBusinessBase <Trainee>, BusinessBase <Trainee> >();
            dependencyContainer.RegisterTransient <IServiceTrainee, ServiceTrainee>();
            dependencyContainer.RegisterTransient <IRepositoryTrainee, RepositoryTrainee>();
            dependencyContainer.RegisterTransient <IBusinessTrainee, BusinessTrainee>();

            dependencyContainer.RegisterTransient <IServiceBase <Department>, ServiceBase <Department> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <Department>, RepositoryBase <Department> >();
            dependencyContainer.RegisterTransient <IBusinessBase <Department>, BusinessBase <Department> >();
            dependencyContainer.RegisterTransient <IServiceDepartment, ServiceDepartment>();
            dependencyContainer.RegisterTransient <IRepositoryDepartment, RepositoryDepartment>();
            dependencyContainer.RegisterTransient <IBusinessDepartment, BusinessDepartment>();


            dependencyContainer.RegisterTransient <IServiceBase <City>, ServiceBase <City> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <City>, RepositoryBase <City> >();
            dependencyContainer.RegisterTransient <IBusinessBase <City>, BusinessBase <City> >();
            dependencyContainer.RegisterTransient <IServiceCity, ServiceCity>();
            dependencyContainer.RegisterTransient <IRepositoryCity, RepositoryCity>();
            dependencyContainer.RegisterTransient <IBusinessCity, BusinessCity>();

            dependencyContainer.RegisterTransient <IServiceBase <Classroom>, ServiceBase <Classroom> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <Classroom>, RepositoryBase <Classroom> >();
            dependencyContainer.RegisterTransient <IBusinessBase <Classroom>, BusinessBase <Classroom> >();
            dependencyContainer.RegisterTransient <IServiceClassroom, ServiceClassroom>();
            dependencyContainer.RegisterTransient <IRepositoryClassroom, RepositoryClassroom>();
            dependencyContainer.RegisterTransient <IBusinessClassroom, BusinessClassroom>();

            dependencyContainer.RegisterTransient <IServiceBase <IskurClassroom>, ServiceBase <IskurClassroom> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <IskurClassroom>, RepositoryBase <IskurClassroom> >();
            dependencyContainer.RegisterTransient <IBusinessBase <IskurClassroom>, BusinessBase <IskurClassroom> >();
            dependencyContainer.RegisterTransient <IServiceIskurClassroom, ServiceIskurClassroom>();
            dependencyContainer.RegisterTransient <IRepositoryIskurClassroom, RepositoryIskurClassroom>();
            dependencyContainer.RegisterTransient <IBusinessIskurClassroom, BusinessIskurClassroom>();

            dependencyContainer.RegisterTransient <IServiceBase <Education>, ServiceBase <Education> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <Education>, RepositoryBase <Education> >();
            dependencyContainer.RegisterTransient <IBusinessBase <Education>, BusinessBase <Education> >();
            dependencyContainer.RegisterTransient <IServiceEducation, ServiceEducation>();
            dependencyContainer.RegisterTransient <IRepositoryEducation, RepositoryEducation>();
            dependencyContainer.RegisterTransient <IBusinessEducation, BusinessEducation>();

            dependencyContainer.RegisterTransient <IServiceBase <EmployeeType>, ServiceBase <EmployeeType> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <EmployeeType>, RepositoryBase <EmployeeType> >();
            dependencyContainer.RegisterTransient <IBusinessBase <EmployeeType>, BusinessBase <EmployeeType> >();
            dependencyContainer.RegisterTransient <IServiceEmployeeType, ServiceEmployeeType>();
            dependencyContainer.RegisterTransient <IRepositoryEmployeeType, RepositoryEmployeeType>();
            dependencyContainer.RegisterTransient <IBusinessEmployeeType, BusinessEmployeeType>();


            dependencyContainer.RegisterTransient <IServiceBase <Branch>, ServiceBase <Branch> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <Branch>, RepositoryBase <Branch> >();
            dependencyContainer.RegisterTransient <IBusinessBase <Branch>, BusinessBase <Branch> >();
            dependencyContainer.RegisterTransient <IServiceBranch, ServiceBranch>();
            dependencyContainer.RegisterTransient <IRepositoryBranch, RepositoryBranch>();
            dependencyContainer.RegisterTransient <IBusinessBranch, BusinessBranch>();

            dependencyContainer.RegisterTransient <IServiceBase <TraineeStatus>, ServiceBase <TraineeStatus> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <TraineeStatus>, RepositoryBase <TraineeStatus> >();
            dependencyContainer.RegisterTransient <IBusinessBase <TraineeStatus>, BusinessBase <TraineeStatus> >();
            dependencyContainer.RegisterTransient <IServiceTraineeStatus, ServiceTraineeStatus>();
            dependencyContainer.RegisterTransient <IRepositoryTraineeStatus, RepositoryTraineeStatus>();
            dependencyContainer.RegisterTransient <IBusinessTraineeStatus, BusinessTraineeStatus>();


            dependencyContainer.RegisterTransient <IServiceBase <TraineeEmploymentStatus>, ServiceBase <TraineeEmploymentStatus> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <TraineeEmploymentStatus>, RepositoryBase <TraineeEmploymentStatus> >();
            dependencyContainer.RegisterTransient <IBusinessBase <TraineeEmploymentStatus>, BusinessBase <TraineeEmploymentStatus> >();
            dependencyContainer.RegisterTransient <IServiceTraineeEmploymentStatus, ServiceTraineeEmploymentStatus>();
            dependencyContainer.RegisterTransient <IRepositoryTraineeEmploymentStatus, RepositoryTraineeEmploymentStatus>();
            dependencyContainer.RegisterTransient <IBusinessTraineeEmploymentStatus, BusinessTraineeEmploymentStatus>();


            dependencyContainer.RegisterTransient <IServiceBase <Employee>, ServiceBase <Employee> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <Employee>, RepositoryBase <Employee> >();
            dependencyContainer.RegisterTransient <IBusinessBase <Employee>, BusinessBase <Employee> >();
            dependencyContainer.RegisterTransient <IServiceEmployee, ServiceEmployee>();
            dependencyContainer.RegisterTransient <IRepositoryEmployee, RepositoryEmployee>();
            dependencyContainer.RegisterTransient <IBusinessEmployee, BusinessTeacher>();

            dependencyContainer.RegisterTransient <IServiceBase <EmployeeHistory>, ServiceBase <EmployeeHistory> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <EmployeeHistory>, RepositoryBase <EmployeeHistory> >();
            dependencyContainer.RegisterTransient <IBusinessBase <EmployeeHistory>, BusinessBase <EmployeeHistory> >();
            dependencyContainer.RegisterTransient <IServiceEmployeeHistory, ServiceEmployeeHistory>();
            dependencyContainer.RegisterTransient <IRepositoryEmployeeHistory, RepositoryEmployeeHistory>();
            dependencyContainer.RegisterTransient <IBusinessEmployeeHistory, BusinessEmployeeHistory>();

            dependencyContainer.RegisterTransient <IServiceBase <ControlEnt>, ServiceBase <ControlEnt> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <ControlEnt>, RepositoryBase <ControlEnt> >();
            dependencyContainer.RegisterTransient <IBusinessBase <ControlEnt>, BusinessBase <ControlEnt> >();
            dependencyContainer.RegisterTransient <IServiceControl, ServiceControl>();
            dependencyContainer.RegisterTransient <IRepositoryControl, RepositoryControl>();
            dependencyContainer.RegisterTransient <IBusinessControl, BusinessControl>();

            dependencyContainer.RegisterTransient <IServiceBase <DataTypeEnt>, ServiceBase <DataTypeEnt> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <DataTypeEnt>, RepositoryBase <DataTypeEnt> >();
            dependencyContainer.RegisterTransient <IBusinessBase <DataTypeEnt>, BusinessBase <DataTypeEnt> >();
            dependencyContainer.RegisterTransient <IServiceDataType, ServiceDataType>();
            dependencyContainer.RegisterTransient <IRepositoryDataType, RepositoryDataType>();
            dependencyContainer.RegisterTransient <IBusinessDataType, BusinessDataType>();

            dependencyContainer.RegisterTransient <IServiceBase <TraineeEmploymentStatusField>, ServiceBase <TraineeEmploymentStatusField> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <TraineeEmploymentStatusField>, RepositoryBase <TraineeEmploymentStatusField> >();
            dependencyContainer.RegisterTransient <IBusinessBase <TraineeEmploymentStatusField>, BusinessBase <TraineeEmploymentStatusField> >();
            dependencyContainer.RegisterTransient <IServiceTraineeEmploymentStatusField, ServiceTraineeEmploymentStatusField>();
            dependencyContainer.RegisterTransient <IRepositoryTraineeEmploymentStatusField, RepositoryTraineeEmploymentStatusField>();
            dependencyContainer.RegisterTransient <IBusinessTraineeEmploymentStatusField, BusinessTraineeEmploymentStatusField>();

            dependencyContainer.RegisterTransient <IServiceBase <TraineeEmploymentStatusReason>,
                                                   ServiceBase <TraineeEmploymentStatusReason> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <TraineeEmploymentStatusReason>, RepositoryBase <TraineeEmploymentStatusReason> >();
            dependencyContainer.RegisterTransient <IBusinessBase <TraineeEmploymentStatusReason>, BusinessBase <TraineeEmploymentStatusReason> >();
            dependencyContainer.RegisterTransient <IServiceTraineeEmploymentStatusReason, ServiceTraineeEmploymentStatusReason>();
            dependencyContainer.RegisterTransient <IRepositoryTraineeEmploymentStatusReason, RepositoryTraineeEmploymentStatusReason>();
            dependencyContainer.RegisterTransient <IBusinessTraineeEmploymentStatusReason, BusinessTraineeEmploymentStatusReason>();

            dependencyContainer.RegisterTransient <IServiceBase <TraineeEmploymentStatusReasonDetail>, ServiceBase <TraineeEmploymentStatusReasonDetail> >();
            dependencyContainer.RegisterTransient <IRepositoryBase <TraineeEmploymentStatusReasonDetail>, RepositoryBase <TraineeEmploymentStatusReasonDetail> >();
            dependencyContainer.RegisterTransient <IBusinessBase <TraineeEmploymentStatusReasonDetail>, BusinessBase <TraineeEmploymentStatusReasonDetail> >();
            dependencyContainer.RegisterTransient <IServiceTraineeEmploymentStatusReasonDetail, ServiceTraineeEmploymentStatusReasonDetail>();
            dependencyContainer.RegisterTransient <IRepositoryTraineeEmploymentStatusReasonDetail, RepositoryTraineeEmploymentStatusReasonDetail>();
            dependencyContainer.RegisterTransient <IBusinessTraineeEmploymentStatusReasonDetail, BusinessTraineeEmploymentStatusReasonDetail>();
        }
コード例 #36
0
 /// <summary>
 /// Gets the list of missing dependencies from the current implementation.
 /// </summary>
 /// <param name="map">The implementation map.</param>
 /// <returns>A list of missing dependencies.</returns>
 public IEnumerable<IDependency> GetMissingDependencies(IDependencyContainer map)
 {
     yield break;
 }
コード例 #37
0
ファイル: PropertyInjectionCall.cs プロジェクト: xerxesb/Hiro
 /// <summary>
 /// Gets the list of missing dependencies from the current implementation.
 /// </summary>
 /// <param name="map">The implementation map.</param>
 /// <returns>A list of missing dependencies.</returns>
 public IEnumerable<IDependency> GetMissingDependencies(IDependencyContainer map)
 {
     foreach (var dependency in GetRequiredDependencies(map))
     {
         if (!map.Contains(dependency))
             yield return dependency;
     }
 }
 /// <summary>
 /// Registers a generator to the resource container with all of the implemented interfaces by the type of resource then generator creates.
 /// </summary>
 /// <param name="container">The container with resources.</param>
 /// <param name="generator">The generator to bind to the container.</param>
 /// <typeparam name="T">Type of value the generator provides when requesting an instance.</typeparam>
 public static void RegisterGeneratorWithInterfaces <T>(this IDependencyContainer container, Func <T> generator)
 {
     container.ThrowIfNull(nameof(container));
     container.RegisterWithInterfaces <T>(new GeneratorBinding <T>(generator));
 }
コード例 #39
0
 public ControllerRouter(IDependencyContainer dependencyContainer)
 {
     this.dependencyContainer = dependencyContainer;
 }
コード例 #40
0
 public void Register(IDependencyContainer container)
 {
     //Do all Win VS registrations here.
     container.Register <IConnectionsDialog, ConnectionsDialog>();
 }
コード例 #41
0
ファイル: StartUp.cs プロジェクト: kriss98/CSharp-Projects
 public override void ConfigureServices(IDependencyContainer dependencyContainer)
 {
     dependencyContainer.RegisterDependency <IUsersService, UsersService>();
     dependencyContainer.RegisterDependency <ITasksService, TasksService>();
     dependencyContainer.RegisterDependency <IReportService, ReportService>();
 }
コード例 #42
0
 public void Register(IDependencyContainer container)
 {
     container.Bind <IWorkflowInstanceService, WorkflowInstanceService>();
 }
コード例 #43
0
ファイル: Startup.cs プロジェクト: Xamlab/RealmDbSample
 public static IDependencyContainer RegisteriOSDependencies(this IDependencyContainer container)
 {
     container.Register <IDatabaseInstallationService, DatabaseInstallationService>();
     return(container);
 }
コード例 #44
0
        public DiscordPlayerCount(IDependencyContainer container) : base(container)
        {
            _playerManager = container.Resolve <IPlayerManager>();

            _webClient = new WebClient();
        }
コード例 #45
0
 public IEnumerator Initialize(IDependencyContainer container)
 {
     yield return(container.Resolve <IF_IContentPluginLoader>().Initialize());
 }
コード例 #46
0
 internal static void RegisterApiDependencies(Func <IRouteOptions> getRouteOptions, IDependencyContainer container)
 => container
 .RegisterType(getRouteOptions, LifetimeTypes.PerApplicationSingleton)
 .RegisterType <IResolver>(() => container, LifetimeTypes.PerApplicationSingleton)
 .RegisterDependency <RepositoryTypesBootstrapper>()
 .RegisterDependency <ApiServicesBootstrapper>()
 .RegisterDependency <ServicesTypesBootstrapper>();
コード例 #47
0
 public void Setup(IDependencyContainer container)
 {
     container.Bind <IF_IContentPluginLoader, IF_ContentPluginLoader>();
 }
コード例 #48
0
ファイル: Bootstrapper.cs プロジェクト: razvanticle/Ergate
 private void ConfigureDependencyContainer()
 {
     this.container      = this.Configuration.GetSetting <IDependencyContainer>();
     this.serviceLocator = this.container.AsServiceLocator;
     Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(this.GetServiceLocator);
 }
コード例 #49
0
ファイル: PluginLogger.cs プロジェクト: willmax4203/Rocket
        public PluginLogger(IDependencyContainer container, IPlugin plugin) : base(container)
        {
            string path = Path.Combine(plugin.WorkingDirectory, "Logs");

            File = Path.Combine(path, plugin.Name + ".log");
        }
コード例 #50
0
 public void Register(IDependencyContainer container)
 {
     // Bind Services
     container.Bind <IMediaMetaService, MediaMetaService>();
     container.Bind <IMediaDataService, MediaDataService>();
 }
コード例 #51
0
ファイル: MvcApplication.cs プロジェクト: nkyurkchiyski/SIS
 public virtual void ConfigureServices(IDependencyContainer dependencyContainer)
 {
 }
コード例 #52
0
 public void Initialize(IDependencyContainer dependencyContainer)
 {
     _main                 = dependencyContainer.Resolve <Main>();
     _gameData             = dependencyContainer.Resolve <GameDataManager>();
     _serverCommunications = dependencyContainer.Resolve <ServerCommunications>();
 }
コード例 #53
0
 public override void ConfigureServices(IDependencyContainer dependencyContainer)
 {
     dependencyContainer.RegisterDependency <IUserService, UserService>();
     dependencyContainer.RegisterDependency <IProductService, ProductService>();
 }
コード例 #54
0
ファイル: TestPlugin.cs プロジェクト: lovenets/Rocket
 public TestPlugin(IDependencyContainer container) : base("TestPlugin", container)
 {
     Logger.LogInformation("Constructing TestPlugin (From plugin)");
 }
コード例 #55
0
ファイル: ServiceProviderBase.cs プロジェクト: Hengle/Hermit
 public abstract void RegisterBindings(IDependencyContainer Container);
コード例 #56
0
 public override void ConfigureServices(IDependencyContainer dependencyContainer)
 {
 }
コード例 #57
0
ファイル: PropertyInjectionCall.cs プロジェクト: xerxesb/Hiro
        /// <summary>
        /// Returns the dependencies required by the current implementation.
        /// </summary>
        /// <param name="map">The implementation map.</param>
        /// <returns>The list of required dependencies required by the current implementation.</returns>
        public IEnumerable<IDependency> GetRequiredDependencies(IDependencyContainer map)
        {
            var requiredDependencies = _implementation.GetRequiredDependencies(map);
            var dependencyList = new List<IDependency>(requiredDependencies);
            var results = new HashedSet<IDependency>(dependencyList);

            var properties = TargetType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            foreach (var property in properties)
            {
                // Skip properties that don't meet the filter criteria
                if (!_propertyFilter(property) || !property.CanWrite)
                    continue;

                var dependency = _propertyDependencyResolver(property);
                if (dependency == null || results.Contains(dependency))
                    continue;

                results.Add(dependency);
            }

            return results;
        }
コード例 #58
0
ファイル: ServiceProviderBase.cs プロジェクト: Hengle/Hermit
 public virtual void Initialization(IDependencyContainer Container)
 {
 }
コード例 #59
0
 /// <summary>
 /// Returns the dependencies required by the current implementation.
 /// </summary>
 /// <returns>The list of required dependencies required by the current implementation.</returns>
 public IEnumerable<IDependency> GetRequiredDependencies(IDependencyContainer map)
 {
     yield break;
 }
コード例 #60
0
 public void Configure(IDependencyContainer container)
 {
     container.RegisterPerRequest <INavigation, TopNavigation>();
     container.Register <ILogger, ASPNETTraceLog>();
 }