コード例 #1
0
        private IServiceProvider BuildServiceProvider <TStorage>(IPhysicalEndPoint <TestAddress> physicalEndPoint,
                                                                 IDateTimeProvider dateTimeProvider,
                                                                 IStoredEntryManager storedEntryManager,
                                                                 IStoredSessionManager storedSessionManager,
                                                                 TStorage coordinationStorage)
            where TStorage : ICoordinationStorage, ISessionStorage
        {
            IServiceCollection services = new ServiceCollection();

            services.AddSingleton <IAddressConversion <TestAddress>, TestAddressSerializer>();
            //services.AddSingleton(physicalEndPoint);
            services.AddSingleton <IPhysicalEndPointMultiplexer <TestAddress> >(p => new PhysicalEndPointMultiplexer <TestAddress>(physicalEndPoint, p.GetService <ILogger <PhysicalEndPointMultiplexer <TestAddress> > >()));
            services.AddSingleton <ICoordinationStorage>(coordinationStorage);
            services.AddSingleton <ISessionStorage>(coordinationStorage);
            services.AddSingleton <ISessionManager, SessionManager>();
            services.AddSingleton <ICoordinationManager, CoordinationManager <TestAddress> >();
            services.AddSingleton(p => Provider.FromServices <ICoordinationManager>(p));
            services.AddSingleton <ISessionProvider, SessionProvider <TestAddress> >();
            services.AddSingleton(dateTimeProvider);
            services.AddSingleton(storedEntryManager);
            services.AddSingleton(storedSessionManager);
            services.AddLogging(options =>
            {
                options.SetMinimumLevel(LogLevel.Trace);
                options.AddDebug();
            });
            return(services.BuildServiceProvider());
        }
コード例 #2
0
 private Task DisposePhysicalEndPointAsync(IPhysicalEndPoint <TAddress> physicalEndPoint)
 {
     return(physicalEndPoint.Assert(p => p != null)
            .DisposeIfDisposableAsync()
            .HandleExceptionsAsync(_logger));
 }