protected override void ConfigureService(IServiceContext serviceContext)
        {
            var instance = new FakeOpenGenericService <PocoClass>(null);

            serviceContext.AddType <PocoClass, PocoClass>(Lifetime.Singleton);
            serviceContext.AddType(typeof(IFakeOpenGenericService <PocoClass>), typeof(FakeService), Lifetime.Singleton);
            serviceContext.AddType(typeof(IFakeOpenGenericService <>), typeof(FakeOpenGenericService <>), Lifetime.Singleton);
            serviceContext.AddInstance <IFakeOpenGenericService <PocoClass> >(instance);
        }
Beispiel #2
0
 public static IServiceContext AddAspectScope(this IServiceContext services)
 {
     if (services == null)
     {
         throw new ArgumentNullException(nameof(services));
     }
     services.AddType <IAspectScheduler, ScopeAspectScheduler>(Lifetime.Scoped);
     services.AddType <IAspectContextFactory, ScopeAspectContextFactory>(Lifetime.Scoped);
     services.AddType <IAspectBuilderFactory, ScopeAspectBuilderFactory>(Lifetime.Scoped);
     return(services);
 }
 public static IServiceContext AddDataAnnotations(this IServiceContext services, params AspectPredicate[] predicates)
 {
     if (services == null)
     {
         throw new ArgumentNullException(nameof(services));
     }
     services.AddType <IDataValidator, AnnotationDataValidator>();
     services.AddType <IPropertyValidator, AnnotationPropertyValidator>();
     services.AddType <IDataStateFactory, DataStateFactory>();
     services.Configuration.Interceptors.AddTyped <DataValidationInterceptorAttribute>(predicates);
     return(services);
 }
 protected override void ConfigureService(IServiceContext serviceContext)
 {
     serviceContext.Configuration.Interceptors.AddTyped <Intercept>(Predicates.ForService("*FakeService"));
     serviceContext.AddType <FakeService>();
     serviceContext.AddDelegate <FakeProperty>(r => new FakeProperty {
         Val = "lemon"
     });
     base.ConfigureService(serviceContext);
 }
Beispiel #5
0
        public static IServiceContext AddConfigurationInject(this IServiceContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.AddType <IServiceResolveCallback, ConfigurationBindResolveCallback>(Lifetime.Singleton);
            return(context);
        }
 protected override void ConfigureService(IServiceContext serviceContext)
 {
     serviceContext.AddType <Test>();
     serviceContext.AddType <IProxyTransient, ProxyTransient>();
 }
Beispiel #7
0
 protected override void ConfigureService(IServiceContext serviceContext)
 {
     serviceContext.AddType <ITransient, Transient>();
 }
 protected void ConfigureServiceInternal(IServiceContext serviceContext)
 {
     serviceContext.AddType <IProxyTransient, ProxyTransient>();
     serviceContext.AddType <ProxyTransient>();
 }
 protected override void ConfigureService(IServiceContext serviceContext)
 {
     serviceContext.AddType <ILogger, Logger>(Lifetime.Singleton);
     serviceContext.AddType(typeof(IRepository <>), typeof(Repository <>), Lifetime.Scoped);
     serviceContext.AddType <IUserService, UserService>();
 }
        private static void TypeSelfRegister(IServiceContext services, DependencyRegisterDescriptor d)
        {
            var lifetime = d.LifetimeType.ToAspectCoreLifetime();

            services.AddType(d.ImplementationTypeSelf, lifetime);
        }