public static void ServiceContainerTest() { var builder = new ServiceContainerBuilder(); builder.AddSingletonProxy <IFly, MonkeyKing>(); using var container = builder.BuildFluentAspectsContainer(options => { options.InterceptAll() .With <LogInterceptor>(); }); container.ResolveService <IFly>() .Fly(); Console.WriteLine(); }
public ServiceContainerBuilderBuildTest(ITestOutputHelper output) { var services = new ServiceContainerBuilder(); services.AddSingleton <IIdGenerator, GuidIdGenerator>(); services.AddSingleton(GuidIdGenerator.Instance); services.AddSingleton <IUserIdProvider, EnvironmentUserIdProvider>(); services.AddSingleton <EnvironmentUserIdProvider>(); services.AddSingleton <IEventPublisher, EventQueuePublisher>(); services.AddSingleton <IOptions <EventQueuePublisherOptions> >( new OptionsWrapper <EventQueuePublisherOptions>(new EventQueuePublisherOptions())); services.AddSingleton <IEventQueue, EventQueueInMemory>(); services.AddSingleton <EventHandlerBase <TestEvent> >(DelegateEventHandler.FromAction <TestEvent>(_ => { })); services.AddSingleton(typeof(IEventHandler <>), typeof(ServiceCollectionBuildTest.TestGenericEventHandler <>)); _serviceProvider = services.BuildFluentAspectsContainer(options => { options.InterceptAll() .With <TestOutputInterceptor>(); }); }