/// <inheritdoc />
        public override ICollection <T> GetCollection <T>()
        {
            if (Collections.TryGetValue(typeof(T), out var collection))
            {
                return((ICollection <T>)collection);
            }

            var noActionCollection = new FlagAsDeletedDecorator <T>(MemoryCache,
                                                                    new FillDefaultValueDecorator <T>(MemoryCache,
                                                                                                      new CacheDecorator <T>(MemoryCache, true,
                                                                                                                             new NoActionCollection <T>()), ActorId));

            if (LogTime)
            {
                var timeLoggedNoActionCollection =
                    new LogTimeDecorator <T>(MemoryCache, noActionCollection, _logger);
                Collections.TryAdd(typeof(T), timeLoggedNoActionCollection);
            }
            else
            {
                Collections.TryAdd(typeof(T), noActionCollection);
            }

            Collections.TryAdd(typeof(T), noActionCollection);
            return(noActionCollection);
        }
Beispiel #2
0
        public override IRepository <T> GetRepository <T>()
        {
            _dbContext.Set <T>();
            var sqlServerRepository = new FlagAsDeletedDecorator <T>(MemoryCache,
                                                                     new FillDefaultValueDecorator <T>(MemoryCache,
                                                                                                       new CacheDecorator <T>(MemoryCache, false,
                                                                                                                              new SqlServerRepository <T>(LoggerFactory, _dbContext)), _loggedInUserProvider));

            if (LogTime)
            {
                var timeLoggedMongoRepository =
                    new LogTimeDecorator <T>(MemoryCache, sqlServerRepository, _logger);
                Repositories.TryAdd(typeof(T), timeLoggedMongoRepository);
            }
            else
            {
                Repositories.TryAdd(typeof(T), sqlServerRepository);
            }
            return(sqlServerRepository);
        }
        /// <inheritdoc />
        public override IRepository <T> GetRepository <T>()
        {
            if (Repositories.TryGetValue(typeof(T), out var repository))
            {
                return((IRepository <T>)repository);
            }
            var mongoRepository = new FlagAsDeletedDecorator <T>(MemoryCache,
                                                                 new FillDefaultValueDecorator <T>(MemoryCache,
                                                                                                   new CacheDecorator <T>(MemoryCache, false,
                                                                                                                          new MongoRepository <T>(LoggerFactory, _mongoDatabase)), ActorId));

            if (LogTime)
            {
                var timeLoggedMongoRepository = new LogTimeDecorator <T>(MemoryCache, mongoRepository, _logger);
                Repositories.TryAdd(typeof(T), timeLoggedMongoRepository);
            }
            else
            {
                Repositories.TryAdd(typeof(T), mongoRepository);
            }
            return(mongoRepository);
        }
Beispiel #4
0
        /// <inheritdoc />
        public override ICollection <T> GetCollection <T>()
        {
            if (Collections.TryGetValue(typeof(T), out var collection))
            {
                return((ICollection <T>)collection);
            }
            var neverRemove     = _typesToCache.Contains(typeof(T));
            var mongoCollection = new FlagAsDeletedDecorator <T>(MemoryCache,
                                                                 new FillDefaultValueDecorator <T>(MemoryCache,
                                                                                                   new CacheDecorator <T>(MemoryCache, neverRemove,
                                                                                                                          new MongoDbCollection <T>(LoggerFactory, _mongoDatabase)), ActorId));

            if (LogTime)
            {
                var timeLoggedMongoDbCollection = new LogTimeDecorator <T>(MemoryCache, mongoCollection, _logger);
                Collections.TryAdd(typeof(T), timeLoggedMongoDbCollection);
            }
            else
            {
                Collections.TryAdd(typeof(T), mongoCollection);
            }

            return(mongoCollection);
        }
        /// <inheritdoc />
        public override IRepository <T> GetRepository <T>()
        {
            if (Repositories.TryGetValue(typeof(T), out var repository))
            {
                return((IRepository <T>)repository);
            }
            var noActionRepository = new FlagAsDeletedDecorator <T>(MemoryCache,
                                                                    new FillDefaultValueDecorator <T>(MemoryCache,
                                                                                                      new CacheDecorator <T>(MemoryCache, true,
                                                                                                                             new NoActionRepository <T>()), ActorId));

            if (LogTime)
            {
                var timeLoggedNoActionRepository =
                    new LogTimeDecorator <T>(MemoryCache, noActionRepository, _logger);
                Repositories.TryAdd(typeof(T), timeLoggedNoActionRepository);
            }
            else
            {
                Repositories.TryAdd(typeof(T), noActionRepository);
            }
            Repositories.TryAdd(typeof(T), noActionRepository);
            return(noActionRepository);
        }