public static TModel Set <TModel>(this IMemoryCacheProvider cacheProvider, object id, TModel value, DateTimeOffset?absoluteExpiration)
        {
            var cacheItem = cacheProvider.ModelKeyGenerator.CreateCacheItem <TModel>(id);

            cacheItem.AbsoluteExpiration = absoluteExpiration;
            return(cacheProvider.Set(cacheItem, value));
        }
Exemplo n.º 2
0
 public CachedUserAuthorizationGrantsProvider(
     IMemoryCacheProvider memoryCacheAdapter
     , IUserGrantService userGrantService
     )
 {
     _memoryCacheAdapter = memoryCacheAdapter;
     _userGrantService   = userGrantService;
 }
        public CurrentUserCommand(IMemoryCacheProvider cache, IMotorSystemContext contex)
        {
            Guard.WhenArgument(cache, "cache").IsNull().Throw();
            Guard.WhenArgument(contex, "context").IsNull().Throw();

            this.context = contex;
            this.cache   = cache;
        }
Exemplo n.º 4
0
 public LossService(AppUnitOfWork appUOW, ILossAssetService LossAssetSrv,
                    IMemoryCacheProvider cacheProvider)
 {
     _appUow        = appUOW;
     _LossRepo      = appUOW.LossRepo;
     _LossAssetSrv  = LossAssetSrv;
     _cacheProvider = cacheProvider;
 }
        public AuthenticationCommand(ICommand command, IMemoryCacheProvider memCache)
        {
            Guard.WhenArgument(command, "command").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();

            this.command = command;
            this.cache   = memCache;
        }
Exemplo n.º 6
0
 public UserService(AppUnitOfWork uow, IMemoryCacheProvider cache,
                    IEmailService emailService, DashboardMenuSp dashboardMenuSp)
 {
     _appUow          = uow;
     _cache           = cache;
     _emailService    = emailService;
     _dashboardMenuSp = dashboardMenuSp;
     _userRepo        = uow.UserRepo;
 }
Exemplo n.º 7
0
 public ChangeUserPassword(IWriter writer, IReader reader, IMotorSystemContext context,
                           IMemoryCacheProvider cache, IHelperMethods helpers)
 {
     this.writer  = writer;
     this.reader  = reader;
     this.context = context;
     this.cache   = cache;
     this.helpers = helpers;
 }
Exemplo n.º 8
0
        public virtual async Task <ActionResult> SignOut([FromServices] IMemoryCacheProvider cache)
        {
            if (User.Identity.IsAuthenticated)
            {
                cache.Remove(GlobalVariables.CacheSettings.MenuModelCacheKey(User.GetUserId()));
                await _httpAccessor.HttpContext.SignOutAsync();
            }

            return(RedirectToAction("SignIn"));
        }
Exemplo n.º 9
0
        public LogoutUserCommand(IMotorSystemContext context, IUserInputProvider userInputProvider, IMemoryCacheProvider memCache)
        {
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(userInputProvider, "userInputProvider").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();

            this.context           = context;
            this.userInputProvider = userInputProvider;
            this.memCache          = memCache;
        }
Exemplo n.º 10
0
 public ValueSetFullCodeListMapper(
     IIsCustomValueStrategy isCustomValue,
     IMemoryCacheProvider memCache,
     Func <string, string[], IReadOnlyCollection <IValueSetCode> > fetchCodes,
     IEnumerable <string> codeSystemCDs)
     : base(isCustomValue)
 {
     this.cache           = memCache;
     this.fetch           = fetchCodes;
     this.codeSystemCodes = codeSystemCDs;
 }
Exemplo n.º 11
0
        public Engine(IWriter writer, IReader reader, ICommandProcessor processor, IMemoryCacheProvider memCache)
        {
            Guard.WhenArgument(writer, "writer").IsNull().Throw();
            Guard.WhenArgument(reader, "reader").IsNull().Throw();
            Guard.WhenArgument(processor, "processor").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();

            this.writer           = writer;
            this.reader           = reader;
            this.commandProcessor = processor;
            this.memCache         = memCache;
        }
Exemplo n.º 12
0
        internal static IValueSet GetCachedValueSetWithAllCodes(this IMemoryCacheProvider cache, string valueSetId, IEnumerable <string> codeSystemCodes)
        {
            var cacheKey = CacheKeys.ValueSetKey(valueSetId, codeSystemCodes);
            var fnd      = (IValueSet)cache.GetItem(cacheKey);

            if (fnd != null && fnd.AllCodesLoaded)
            {
                return(fnd);
            }

            return(null);
        }
Exemplo n.º 13
0
        public LoginUserCommand(IUserInputProvider userInputProvider, IMotorSystemContext context,
                                IHelperMethods helpers, IMemoryCacheProvider memCache)
        {
            Guard.WhenArgument(userInputProvider, "userInputProvider").IsNull().Throw();
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(helpers, "helpers").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();

            this.userInputProvider = userInputProvider;
            this.context           = context;
            this.helpers           = helpers;
            this.memCache          = memCache;
        }
Exemplo n.º 14
0
        public CreateOfferCommand(IMotorSystemContext context, IModelFactory factory, IOfferInputProvider offerInputProvider
                                  , IMemoryCacheProvider memCache)
        {
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(factory, "factory").IsNull().Throw();
            Guard.WhenArgument(offerInputProvider, "offerInputProvider").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();

            this.context            = context;
            this.factory            = factory;
            this.offerInputProvider = offerInputProvider;
            this.memCache           = memCache;
        }
Exemplo n.º 15
0
 public ValueSetShortCodeListMapper(
     IIsCustomValueStrategy isCustomValue,
     IMemoryCacheProvider memCache,
     ILookup <string, IValueSetCode> lookup,
     IDictionary <string, IValueSet> previouslyCached,
     Func <string, string[], int> getCount,
     IEnumerable <string> codeSystemCodes)
     : base(isCustomValue)
 {
     this.cache         = memCache;
     this.lookupCodes   = lookup;
     this.stash         = previouslyCached;
     this.getCount      = getCount;
     this.codeSystemCds = codeSystemCodes.ToArray();
 }
Exemplo n.º 16
0
        public CreateUserCommand(IMotorSystemContext context, IUserInputProvider user, IModelFactory userModel,
                                 IMemoryCacheProvider memCache, IHelperMethods helpers)
        {
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(user, "user").IsNull().Throw();
            Guard.WhenArgument(userModel, "userModel").IsNull().Throw();
            Guard.WhenArgument(memCache, "memCache").IsNull().Throw();
            Guard.WhenArgument(helpers, "helpers").IsNull().Throw();

            this.context      = context;
            this.user         = user;
            this.modelFactory = userModel;
            this.memCache     = memCache;
            this.helpers      = helpers;
        }
        public CreateCommentCommand(IMotorSystemContext context, IModelFactory factory,
                                    ICommentInputProvider commentInputProvider, IMemoryCacheProvider cache, IDateTimeProvider datetimeProvider)
        {
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(factory, "factory").IsNull().Throw();
            Guard.WhenArgument(commentInputProvider, "commentInputProvider").IsNull().Throw();
            Guard.WhenArgument(cache, "cache").IsNull().Throw();
            Guard.WhenArgument(datetimeProvider, "datetimeProvider").IsNull().Throw();

            this.context = context;
            this.factory = factory;
            this.commentInputProvider = commentInputProvider;
            this.cache            = cache;
            this.datetimeProvider = datetimeProvider;
        }
Exemplo n.º 18
0
 public SqlValueSetRepository(
     SharedContext sharedContext,
     Lazy <ClientTermContext> clientTermContext,
     IMemoryCacheProvider cache,
     ILogger logger,
     IValueSetCodeRepository valsetCodeRepository,
     IPagingStrategy <ValueSetDescriptionDto, IValueSet> pagingStrategy,
     IIsCustomValueStrategy isCustomValueStrategy)
 {
     this.clientTermContext      = clientTermContext;
     this.SharedContext          = sharedContext;
     this.Logger                 = logger;
     this.valueSetCodeRepository = valsetCodeRepository;
     this.Cache          = cache;
     this.pagingStrategy = pagingStrategy;
     this.isCustomValue  = isCustomValueStrategy;
 }
        public CustomCookieAuthenticationEvents(IMemoryCacheProvider memoryCacheProvider, IApplicationReadOnlyDbContext context)
        {
            _memoryCacheProvider = memoryCacheProvider;
            _context             = context;

            OnRedirectToLogin = (context) =>
            {
                context.Response.StatusCode = 401;
                return(Task.CompletedTask);
            };

            OnRedirectToAccessDenied = (context) =>
            {
                context.Response.StatusCode = 403;
                return(Task.CompletedTask);
            };
        }
        public static async Task <TModel> GetOrCreateAsync <TModel, TKey>(this IMemoryCacheProvider cacheProvider,
                                                                          TKey id,
                                                                          Func <TKey, CacheItem, Task <TModel> > factory,
                                                                          DateTimeOffset?absoluteExpiration = null)
            where TModel : IModelKey <TKey>
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

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

            var cacheItem = cacheProvider.ModelKeyGenerator.CreateCacheItem <TModel>(id);

            if (typeof(TKey) == typeof(String))
            {
                if (cacheProvider.TryGetValue(cacheItem, out IModelKey <string> value))
                {
                    return((TModel)value);
                }
            }

            if (typeof(TKey).IsNumericType())
            {
                if (cacheProvider.TryGetValue(cacheItem, out IModelKey <long> value))
                {
                    return((TModel)value);
                }
            }

            var instance = await factory.Invoke(id, cacheItem);

            return(Set(cacheProvider, id, instance, absoluteExpiration));
        }
Exemplo n.º 21
0
 public static Maybe <T> GetItem <T>(this IMemoryCacheProvider cache, string key, Func <object> getter)
 {
     return(cache.GetItem(key, getter).Select(o => (T)o));
 }
Exemplo n.º 22
0
 public static Maybe <T> GetItem <T>(this IMemoryCacheProvider cache, string key)
 {
     return(cache.GetItem(key).Select(o => (T)o));
 }
        public static TModel Set <TModel>(this IMemoryCacheProvider cacheProvider, object id, TModel value)
        {
            var cacheItem = cacheProvider.ModelKeyGenerator.CreateCacheItem <TModel>(id);

            return(cacheProvider.Set(cacheItem, value));
        }
 public CachingManagerFactory(IMemoryCacheProvider cache)
 {
     this.cache = cache;
 }
Exemplo n.º 25
0
 public ActionController(IActionService actionBiz, IMemoryCacheProvider cache)
 {
     _actionSrv = actionBiz;
     _cache     = cache;
 }
Exemplo n.º 26
0
 public LoggingFactory(IMemoryCacheProvider memoryCacheProvider, IConfigurationProvider configurationRepository)
 {
     _memoryCacheProvider     = memoryCacheProvider ?? throw new ArgumentNullException(nameof(memoryCacheProvider));
     _configurationRepository = configurationRepository ??
                                throw new ArgumentNullException(nameof(configurationRepository));
 }
 public CodeSystemCachingManager(IMemoryCacheProvider cache)
 {
     this.cache = cache;
 }
Exemplo n.º 28
0
 public AppCache(IMemoryCacheProvider memoryCacheProvider, IHttpContextCacheProvider httpContextCacheProvider)
 {
     this.memoryCacheProvider      = memoryCacheProvider;
     this.httpContextCacheProvider = httpContextCacheProvider;
 }
 public ValueSetCachingManager(IMemoryCacheProvider cache)
 {
     this.cache = cache;
 }
Exemplo n.º 30
0
 public DataContextProvider(IMemoryCacheProvider memoryCacheProvider)
 {
     this.memoryCacheProvider = memoryCacheProvider;
     Load();
 }