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); }
private static void TypeToInstanceRegister(IServiceContext services, DependencyRegisterDescriptor d) { var lifetime = d.LifetimeType.ToAspectCoreLifetime(); switch (lifetime) { case Lifetime.Singleton: services.AddInstance(d.ServiceType, d.InstanceOfImplementation); break; default: throw new InvalidOperationException("Invalid operation for scoped or Transient mode."); } }