Example #1
0
 public RedisEventBus(IRedisRepository _redisRepository, ILogger <RedisEventBus> _logger, IServiceProvider _serviceProvider, ISubscribeMessageStorage _messageStorage)
 {
     redisSubscribe  = _redisRepository.Subscribe;
     logger          = _logger;
     serviceProvider = _serviceProvider;
     messageStorage  = _messageStorage;
 }
Example #2
0
 public GetOrderWithIdRequestHandler(
     IOrderRepository <Order> repository,
     IRedisRepository redisRepository)
 {
     _repository      = repository ?? throw new ArgumentNullException(nameof(repository));
     _redisRepository = redisRepository ?? throw new ArgumentNullException(nameof(redisRepository));
 }
Example #3
0
 /// <summary>
 /// 建構式
 /// </summary>
 /// <param name="logger">logger</param>
 /// <param name="mapper">mapper</param>
 /// <param name="mgtRepository">mgtRepository</param>
 /// <param name="redisRepository">redisRepository</param>
 public MgtService(ILogger <MgtService> logger, IMapper mapper, IMgtRepository mgtRepository, IRedisRepository redisRepository)
 {
     this.logger          = logger;
     this.mapper          = mapper;
     this.mgtRepository   = mgtRepository;
     this.redisRepository = redisRepository;
 }
Example #4
0
 public RatesControllerTest()
 {
     _logger = new RatesControllerLogerFake();
     _distributedCacheFake = new DistributedCacheFake();
     _redisRepository      = new RedisRepository(_distributedCacheFake, null);
     _ratesController      = new RatesController(_redisRepository, _logger);
 }
Example #5
0
 public RedisSubscribeEvent(IRedisRepository _redis, ILogger <RedisSubscribeEvent> _logger,
                            ISubscribeHandler _subscribeHandler)
 {
     redis            = _redis;
     logger           = _logger;
     subscribeHandler = _subscribeHandler;
 }
Example #6
0
 public PartyHub(IDistributedCache cache, IRedisRepository redisRepository, ILadderService ladderService, TelemetryClient telemetry)
 {
     _cache           = cache;
     _redisRepository = redisRepository;
     _ladderService   = ladderService;
     _telemetry       = telemetry;
 }
        public static void Init(TestContext context)
        {
            IConfiguration     configurationProvider = CreateConfigurationProvider();
            IRedisCacheFactory redisCacheFactory     = new RedisCacheFactory(configurationProvider);

            _redisRepository = new RedisRepository(redisCacheFactory);
        }
Example #8
0
 public UserAuth(IHttpContextAccessor httpContextAccessor, IRedisRepository redisRepository)
 {
     Console.WriteLine($"UserAuth:{redisRepository}");
     this._accessor       = httpContextAccessor;
     this.redisRepository = redisRepository;
     Console.WriteLine($"UserAuth.1:{redisRepository}");
 }
Example #9
0
        public LocalJobTest()
        {
            _mongoRepository         = new MongoRepositoryFake();
            _redisRepository         = new RedisRepositoryFake();
            _exchangeProviderFactory = new ExchangeProviderFactoryFake();

            _job = new LocalJob(_exchangeProviderFactory, _mongoRepository, _redisRepository, null);
        }
 public RedisController(DependencyInjectionManager manager)
 {
     _manager = manager;
     using (var scope = _manager.ServiceProvider.CreateScope())
     {
         _redisRepo = scope.ServiceProvider.GetService <IRedisRepository>();
     }
 }
 public RedisCachingRepository(string connectionString, TimeSpan throttlingInterval,
                               CancellationToken cancellationToken)
 {
     _inner = new RedisRepository(connectionString);
     _cache = new ConcurrentDictionary <string, uint>();
     _queue = new ConcurrentQueue <QueueItem>();
     _throttlingInterval = throttlingInterval;
     _cancellationToken  = cancellationToken;
 }
Example #12
0
 public RedisTest()
 {
     //注入redis仓储服务
     services.AddRedisRepository(options =>
     {
         options.Connection  = new string[] { "" };
         options.RedisPrefix = new RedisPrefixKey();
     });
     redis = services.BuildServiceProvider().GetService <IRedisRepository>();
 }
Example #13
0
 public OERJob(IExchangeProviderFactory exchangeProviderFactory,
               IMongoRepository mongoRepository,
               IRedisRepository redisRepository,
               ILogger <OERJob> logger)
 {
     _exchangeProviderFactory = exchangeProviderFactory;
     _mongoRepository         = mongoRepository;
     _redisRepository         = redisRepository;
     _logger = logger;
 }
Example #14
0
 public BaseService(
     IUnitOfWork uow,
     ISQLRepository <T, Tid> sqlServerRepository,
     IRedisRepository <T, Tid> redisRepository,
     AbstractValidator <T> validator)
 {
     _uow = uow;
     _sqlServerRepository = sqlServerRepository;
     _redisRepository     = redisRepository;
     _validator           = validator;
 }
        public static void Init(TestContext context)
        {
            IConfiguration configurationProvider = CreateConfigurationProvider();
            ICosmosFactory cosmosfactory         = new CosmosFactory(configurationProvider);

            _cosmosRepository = A.Fake <SqlCosmosRepository>(arg => arg.WithArgumentsForConstructor(new object[] { cosmosfactory }));
            IRedisCacheFactory redisCacheFactory = new RedisCacheFactory(configurationProvider);

            _redisRepository      = new RedisRepository(redisCacheFactory);
            _writeThroughStrategy = A.Fake <WriteThroughStrategy>(x =>
                                                                  x.WithArgumentsForConstructor(new Object[] { _redisRepository, _cosmosRepository }));
        }
Example #16
0
 public UserService(
     IConfiguration config,
     IRepository repository,
     IMongoRepository mongoUserRepository = null,
     IRedisRepository redisRepository     = null
     )
 {
     _useDb               = (ConnectDb)int.Parse(config.GetSection(DbConnectionConst.UseDbKey).Value);
     _userRepository      = repository;
     _mongoUserRepository = mongoUserRepository;
     _redisUserRepository = redisRepository;
 }
Example #17
0
 public LadderService(
     IHostingEnvironment env,
     ILogger <LadderService> log,
     IExternalService externalService,
     IRedisRepository redisRepository
     )
 {
     _log             = log;
     _env             = env;
     _externalService = externalService;
     _redisRepository = redisRepository;
 }
 public BasketService(IMongoRepository <Basket> mongoRepository,
                      ISQLRepository <Product> productRepository,
                      ISQLRepository <Stock> stockRepository,
                      IRedisRepository redisRepository,
                      IBasketRepository basketRepository)
 {
     _basketRepository  = basketRepository;
     _mongoRepository   = mongoRepository;
     _productRepository = productRepository;
     _stockRepository   = stockRepository;
     _redisRepository   = redisRepository;
 }
        public static void Init(TestContext context)
        {
            IConfiguration configurationProvider = CreateConfigurationProvider();
            ICosmosFactory cosmosfactory         = new CosmosFactory(configurationProvider);

            // creating a fake instance of cosmos so as to be able to asset the invocations using fakeiteasy
            // note: this is fake instance and does not hold a reference to the actual cosmos DB
            _cosmosRepository = A.Fake <ICosmosRepository>();
            IRedisCacheFactory redisCacheFactory = new RedisCacheFactory(configurationProvider);

            _redisRepository     = new RedisRepository(redisCacheFactory);
            _readThroughStrategy = A.Fake <ReadThroughStrategy>(x =>
                                                                x.WithArgumentsForConstructor(new Object[] { _redisRepository, _cosmosRepository }));
        }
Example #20
0
        public MongoDBRepository()
        {
            #region Initialize
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            var configuration = builder.Build();

            if (configuration.GetChildren().Count() > 0)
            {
                _mongoDBConnectionString = configuration["MongoRedi:MongoDBConnectionString"];
                _mongoDBDatabase         = configuration["MongoRedi:MongoDBDatabase"];

                _redisConnectionString = configuration["MongoRedi:RedisConnectionString"];
                _redisDatabase         = configuration["MongoRedi:RedisDatabase"];

                _enableCache = Convert.ToBoolean(configuration["MongoRedi:Cache"]);
            }
            else
            {
                _mongoDBConnectionString = ConfigurationManager.AppSettings["MongoRedi_MongoDBConnectionString"];
                _mongoDBDatabase         = ConfigurationManager.AppSettings["MongoRedi_MongoDBDatabase"];

                _redisConnectionString = ConfigurationManager.AppSettings["MongoRedi_RedisConnectionString"];
                _redisDatabase         = ConfigurationManager.AppSettings["MongoRedi_RedisDatabase"];

                _enableCache = Convert.ToBoolean(ConfigurationManager.AppSettings["MongoRedi_Cache"]);
            }
            #endregion

            _mongoClient   = new MongoClient(_mongoDBConnectionString);
            _mongoDatabase = _mongoClient.GetDatabase(_mongoDBDatabase);

            var collectionName =
                (typeof(TCollection).GetCustomAttributes(typeof(CollectionNameAttribute), true)[0] as CollectionNameAttribute).CollectionName;
            _collection = _mongoDatabase.GetCollection <TCollection>(collectionName);

            _cacheCollection = typeof(TCollection).IsDefined(typeof(CacheCollectionAttribute), false) && _enableCache;
            _cacheDocument   = typeof(TCollection).IsDefined(typeof(CacheDocumentAttribute), false) && _enableCache;

            if (_cacheCollection || _cacheDocument)
            {
                _redisRepository = new RedisRepository(_redisConnectionString, _redisDatabase);
            }
        }
        public IActionResult Register([FromBody] RegisterModel model,
                                      [FromServices] IRedisRepository redisRepository,
                                      [FromServices] ITentantRedisResolver tentantResolver)
        {
            var result = tentantResolver.Find();

            using (var context = new TenantDbContext(result.Tenant))
            {
                var repository = new EfRepository <User>(context);
                repository.Insert(new User {
                    Name = "unkown", Password = "******"
                });
            }

            //返回ID
            return(Ok());
        }
Example #22
0
        public void AddRedisBranch_AddBranchesToServiceCollectionAndBuildProvider_GetRedisBranch()
        {
            //Arrange
            IServiceCollection services = new ServiceCollection();

            services.AddSingleton <IConnectionMultiplexer>(sp =>
            {
                return(FakesFactory.CreateConnectionMultiplexerFake());
            });

            //Act
            services.AddRedisBranch(Assembly.GetExecutingAssembly());
            ServiceProvider provider = services.BuildServiceProvider();
            IRedisRepository <StockEntity> notNullStockEntity = provider.GetRequiredService <IRedisRepository <StockEntity> >();

            //Assert
            Assert.NotNull(notNullStockEntity);
        }
Example #23
0
 public EfTokenRepository(DatabaseContext context, IRedisRepository <TokenUser> redisRepository, IConfiguration configuration)
 {
     this._context         = context;
     this._redisRepository = redisRepository;
     _configuration        = configuration;
 }
 public DeleteByScoreController(IRedisRepository redisRepository, IRedisRepositorySortedSet redisRepositorySortedSet)
 {
     _redisRepository          = redisRepository;
     _redisRepositorySortedSet = redisRepositorySortedSet;
 }
Example #25
0
 public CheckLoginAttribute(IRedisRepository redisRepository)
 {
     this.redisRepository = redisRepository;
 }
Example #26
0
 public HealthController(IRedisRepository redisRepository)
 {
     _redisRepository = redisRepository;
 }
Example #27
0
 public MongoDockerCommandsRepository(IRedisRepository redisRepository)
 {
     _redisRepository = redisRepository;
     _context         = new DockerCommandsContext();
 }
 public CommonController(IRedisRepository redis)
 {
     _redis = redis;
 }
 public RefreshTokenProvider()
 {
     IDependencyResolver container = GlobalConfiguration.Configuration.DependencyResolver;
     _redisRepo = (IRedisRepository)container.GetService(typeof(IRedisRepository));
 }
 public RefreshTokenProvider(IRedisRepository redisRepository)
 {
     _redisRepo = redisRepository;
 }
 public AccountController(IUserRepository userRepository, IRedisRepository redis)
 {
     _redis = redis;
     _userRepository = userRepository;
 }
Example #32
0
 public BaseRepository()
 {
     Db = new FsDataContext();
     RedisRepository = new RedisRepository();
 }
 public FirstBusiness(IRedisRepository redisRepository)
 {
     _redisRepository = redisRepository;
 }
Example #34
0
 public PartyHub(IDistributedCache cache, IRedisRepository redisRepository, ILadderService ladderService)
 {
     _cache           = cache;
     _redisRepository = redisRepository;
     _ladderService   = ladderService;
 }
Example #35
0
 public RedisService(IRedisRepository redisRepository)
 {
     _redisRepository = redisRepository;
 }