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); }
private static void ResolvedInstanceSelfFuncRegister(IServiceContext services, DependencyRegisterDescriptor d) { var lifetime = d.LifetimeType.ToAspectCoreLifetime(); switch (lifetime) { case Lifetime.Scoped: services.AddDelegate(p => d.ResolveFuncForImplementation(p.ToAbstract()), Lifetime.Scoped); break; case Lifetime.Singleton: services.AddDelegate(p => d.ResolveFuncForImplementation(p.ToAbstract()), Lifetime.Singleton); break; case Lifetime.Transient: services.AddDelegate(p => d.ResolveFuncForImplementation(p.ToAbstract())); break; default: services.AddDelegate(p => d.ResolveFuncForImplementation(p.ToAbstract())); break; } }
private static void TypeToInstanceFuncRegister(IServiceContext services, DependencyRegisterDescriptor d) { var lifetime = d.LifetimeType.ToAspectCoreLifetime(); services.AddDelegate(d.ServiceType, r => d.InstanceFuncForImplementation(), lifetime); }