public override IServiceDefinitionCollection RegisterServices(IServiceDefinitionCollection serviceCollection)
        {
            serviceCollection.AddTransient <IDevJokeRepository, DevJokeRepository>();

            serviceCollection.AddTransient <IDevJokeService, DevJokeService>();

            return(serviceCollection);
        }
        public DefaultServiceCollection(IServiceDefinitionCollection serviceDefinitionCollection)
        {
            new DefaultAutofacServicesRegistor().Registor(this.mainBuilder, serviceDefinitionCollection.ServiceDefinitionCollection);
            this.mainContainer = this.mainBuilder.Build();
            var anotherBuilder = new ContainerBuilder();

            anotherBuilder.RegisterInstance(this).As <IServiceCollection>().SingleInstance();
            anotherBuilder.Update(this.mainContainer.ComponentRegistry);
        }
Exemple #3
0
        /// <summary>
        /// Register service with service type and implement instance.
        /// </summary>
        /// <param name="services">Service definition collection.</param>
        /// <param name="serviceType">Service type.</param>
        /// <param name="instance">Implement instance.</param>
        /// <param name="lifeTime">Service life time.</param>
        public static IServiceDefinitionCollection RegisterService(this IServiceDefinitionCollection services, Type serviceType, object instance, ServiceLifeTime lifeTime)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("Service type is null.");
            }

            services.AddOrUpdateServiceDefinition(serviceType,
                                                  CreateServiceDefine(serviceType, instance, null, null, lifeTime),
                                                  (type, old) => CreateServiceDefine(serviceType, instance, null, null, lifeTime));

            return(services);
        }
Exemple #4
0
        public override IServiceDefinitionCollection RegisterServices(IServiceDefinitionCollection serviceCollection)
        {
            base.RegisterServices(serviceCollection);
            serviceCollection.AddTransient <IRelationalEntityConfiguration, DevJokeConfiguration>();
            serviceCollection.AddTransient <DevFunStorage>();
            serviceCollection.AddTransient <IStorage, DevFunStorage>();
            serviceCollection.AddTransient <StorageSession <DevFunStorage> >();
            serviceCollection.AddTransient <IStorageFactory <IStorage>, StorageFactory <DevFunStorage> >();
            serviceCollection.AddTransient <IStorageFactory <IDevFunStorage>, StorageFactory <DevFunStorage> >();
            serviceCollection.AddTransient <IStorageFactory <DevFunStorage>, StorageFactory <DevFunStorage> >();



            return(serviceCollection);
        }
Exemple #5
0
        public override IServiceDefinitionCollection RegisterServices(IServiceDefinitionCollection serviceCollection)
        {
            serviceCollection.AddTransient <IDevJokeRepository, DevJokeRepository>();
            serviceCollection.AddTransient <ICategoryRepository, CategoryRepository>();

            serviceCollection.AddDefaultDetachedEntityMapper <Category>();
            serviceCollection.AddDefaultDetachedEntityMapper <DevJoke>();
            serviceCollection.AddSingleton <IDetachedEntityMapperFactory, DetachedEntityMapperFactory>();

            serviceCollection.AddDefaultEntityMapper <Category, CategoryDto, int>(c => c.Id, c => c.Id);
            serviceCollection.AddEntityMapper <DevJoke, DevJokeDto, DevJokeMappingDtoMapperConfiguration, int>(d => d.Id, d => d.Id);

            serviceCollection.AddTransient <IDevJokeService, DevJokeService>();
            serviceCollection.AddTransient <ICategoryService, CategoryService>();

            serviceCollection.AddMapperFactories();

            return(serviceCollection);
        }
 public override IServiceDefinitionCollection RegisterServices(IServiceDefinitionCollection serviceCollection)
 {
     serviceCollection.AddTransient <IDataInitializer, TestDataInitializer>();
     return(serviceCollection);
 }
Exemple #7
0
        /// <summary>
        /// Add auto setup service.
        /// </summary>
        /// <param name="services">Service collection.</param>
        /// <returns>Service collection.</returns>
        public static void RegisterService()
        {
            IServiceDefinitionCollection serviceDefinitionCollection = DependencyServiceRepository.BuildServiceDefinitionCollection();

            servicesCollection = new DefaultServiceCollection(serviceDefinitionCollection);
        }
Exemple #8
0
 /// <summary>
 /// Register service with service type and implement instance.
 /// </summary>
 /// <param name="services">Service definition collection.</param>
 /// <param name="serviceType">Service type.</param>
 /// <param name="instance">Implement instance.</param>
 public static IServiceDefinitionCollection RegisterService(this IServiceDefinitionCollection services, Type serviceType, object instance)
 {
     return(services.RegisterService(serviceType, instance, ServiceLifeTime.Scope));
 }
Exemple #9
0
 /// <summary>
 /// Register service with service type and implement instance.
 /// </summary>
 /// <typeparam name="TServiceType">Service type.</typeparam>
 /// <param name="services">Service definition collection.</param>
 /// <param name="instance">Implement instance.</param>
 public static IServiceDefinitionCollection RegisterService <TServiceType>(this IServiceDefinitionCollection services, object instance, ServiceLifeTime lifeTime)
 {
     return(services.RegisterService(typeof(TServiceType), instance, lifeTime));
 }
Exemple #10
0
 /// <summary>
 /// Register service with service type and implement type.
 /// </summary>
 /// <typeparam name="TServiceType">Service type.</typeparam>
 /// <typeparam name="TImplementType">Implement type.</typeparam>
 /// <param name="services">Service definition collection.</param>
 /// <param name="lifeTime">Service life time.</param>
 public static IServiceDefinitionCollection RegisterService <TServiceType, TImplementType>(this IServiceDefinitionCollection services, ServiceLifeTime lifeTime)
 {
     return(services.RegisterService(typeof(TServiceType), typeof(TImplementType), lifeTime));
 }
Exemple #11
0
 /// <summary>
 /// Register service with service type and implement factory.
 /// </summary>
 /// <typeparam name="TServiceType">Service type.</typeparam>
 /// <param name="services">Service definition collection.</param>
 /// <param name="factory">Implement factory.</param>
 /// <param name="lifeTime">Service life time.</param>
 public static IServiceDefinitionCollection RegisterService <TServiceType>(this IServiceDefinitionCollection services, Func <object> factory, ServiceLifeTime lifeTime)
 {
     return(services.RegisterService(typeof(TServiceType), factory, lifeTime));
 }