コード例 #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
        public CoordinationStorage(IFilterableDatabase database,
                                   IStoredSessionManager storedSessionManager,
                                   IStoredEntryManager storedEntryManager)
        {
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }

            if (storedSessionManager == null)
            {
                throw new ArgumentNullException(nameof(storedSessionManager));
            }

            if (storedEntryManager == null)
            {
                throw new ArgumentNullException(nameof(storedEntryManager));
            }

            _database             = database;
            _storedSessionManager = storedSessionManager;
            _storedEntryManager   = storedEntryManager;
        }
コード例 #3
0
        public SessionManager(ISessionStorage storage,
                              IStoredSessionManager storedSessionManager,
                              IDateTimeProvider dateTimeProvider)
        {
            if (storage == null)
            {
                throw new ArgumentNullException(nameof(storage));
            }

            if (storedSessionManager == null)
            {
                throw new ArgumentNullException(nameof(storedSessionManager));
            }

            if (dateTimeProvider == null)
            {
                throw new ArgumentNullException(nameof(dateTimeProvider));
            }

            _storage = storage;
            _storedSessionManager = storedSessionManager;
            _dateTimeProvider     = dateTimeProvider;
        }