Esempio n. 1
1
 public FilesController(IFileSystemService fileSystemService, IUnitOfWorkFactory unitOfWorkFactory, ILogService logService, ICacheWrapper cacheWrapper)
 {
     _fileSystemService = fileSystemService;
     _unitOfWorkFactory = unitOfWorkFactory;
     _logService = logService;
     _cacheWrapper = cacheWrapper;
 }
Esempio n. 2
0
 public BusinessContextController(IProgressConnection connection, ICacheWrapper appCache)
 {
     this.connection            = connection;
     this._appCache             = appCache;
     this._tokenObject          = ApplicationCookieUtilities.Principal(HttpContext.Current.User, out var _);
     this._appCache.TokenObject = this._tokenObject;
 }
Esempio n. 3
0
        public static async Task <T> GetOrAddAsync <T>(this ICacheWrapper cache,
                                                       string key,
                                                       SemaphoreSlim semaphore,
                                                       Func <Task <T> > func) where T : class
        {
            var result = cache[key] as T;

            if (result != null)
            {
                return(result);
            }
            await semaphore.WaitAsync().ConfigureAwait(false);

            try {
                result = cache[key] as T;
                if (result != null)
                {
                    return(result);
                }
                result = await func.Invoke();

                cache[key] = result;
                return(result);
            }
            finally {
                semaphore.Release();
            }
        }
Esempio n. 4
0
        public FloodMonitoringServices(ILogging logger,
                                       IConfigurationServices config, ICacheWrapper cache, IExternalServiceWrapper externalService)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            this._logger = logger;

            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            this._config = config;

            if (cache == null)
            {
                throw new ArgumentNullException("cache");
            }

            this._memoryCache = cache;

            if (externalService == null)
            {
                throw new ArgumentNullException("externalService");
            }

            this._externalService = externalService;
        }
Esempio n. 5
0
 public BaseController()
 {
     sessionWrapper   = new SessionCacheWrapper(System.Web.HttpContext.Current.Session);
     requestWrapper   = new RequestWrapper(System.Web.HttpContext.Current.Request);
     applicationCache = new ApplicationCache(System.Web.HttpContext.Current.Application);
     memoryCache      = new MemoryCache();
 }
Esempio n. 6
0
 public BaseController(ICacheWrapper sessionWrapper, ICacheWrapper applicationCache, ICacheWrapper memoryCache, IRequestWrapper requestWrapper)
 {
     this.sessionWrapper   = sessionWrapper;
     this.requestWrapper   = requestWrapper;
     this.applicationCache = applicationCache;
     this.memoryCache      = memoryCache;
 }
Esempio n. 7
0
 public FileNotFoundHandler(WebExtensionsToRoute webExtensions, IMaterialCMSRoutingErrorHandler errorHandler, ICacheWrapper cacheWrapper, IControllerManager controllerManager)
 {
     _webExtensions     = webExtensions;
     _errorHandler      = errorHandler;
     _cacheWrapper      = cacheWrapper;
     _controllerManager = controllerManager;
 }
Esempio n. 8
0
 protected RepositoryWithCache(ICacheWrapper cache, IConnectionFactory factory = null, ISqlWorker broker = null) : base(factory, broker)
 {
     if (cache == null)
     {
         throw new ArgumentNullException("cache");
     }
     this.cache = cache;
 }
Esempio n. 9
0
        public SecurityUserService(ISettingItemService settingsService, IUserCategoryService userCategoryService, IUnitOfWorkFactory unitOfWorkFactory, ICacheWrapper cacheWrapper)
        {
            _settingsService = settingsService;
            _userCategoryService = userCategoryService;

            _unitOfWorkFactory = unitOfWorkFactory;
            _cacheWrapper = cacheWrapper;
        }
Esempio n. 10
0
 public ImagesController(
     IDatabaseAccess _database,
     IStorageProvider _storage,
     ICacheWrapper _cache)
 {
     database = _database;
     storage  = _storage;
     cache    = _cache;
 }
Esempio n. 11
0
 public WordService(ISecurityUserService securityUserService,
     IFileSystemService fileSystemService,
     IPathHelper pathHelper,
     ICacheWrapper cache,
     IUnitOfWorkFactory unitOfWorkFactory)
 {
     _securityUserService = securityUserService;
     _fileSystemService = fileSystemService;
     _pathHelper = pathHelper;
     _cache = cache;
     _unitOfWorkFactory = unitOfWorkFactory;
 }
Esempio n. 12
0
        public SettingsServiceCached(Lazy<ISettingsService> settingsService, 
            ICacheWrapper cacheWrapper,
            ISettingsCacheParameters settingsCacheParameters)
        {
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));
            if (cacheWrapper == null) throw new ArgumentNullException(nameof(cacheWrapper));
            if (settingsCacheParameters == null) throw new ArgumentNullException(nameof(settingsCacheParameters));

            _settingsService = settingsService;
            _cacheWrapper = cacheWrapper;
            _settingsCacheParameters = settingsCacheParameters;
        }
        public LocalizationsFromDatabaseStoreCached(Lazy<ILocalizationsDatabaseStore> localizationsDatabaseStore,
            ICacheWrapper cacheWrapper, 
            ILocalizationCacheParameters localizationCacheSettings)
        {
            if (localizationsDatabaseStore == null)
                throw new ArgumentNullException(nameof(localizationsDatabaseStore));

            if (cacheWrapper == null)
                throw new ArgumentNullException(nameof(cacheWrapper));

            if (localizationCacheSettings == null)
                throw new ArgumentNullException(nameof(localizationCacheSettings));

            _localizationsDatabaseStore = localizationsDatabaseStore;
            _cacheWrapper = cacheWrapper;
            _localizationCacheSettings = localizationCacheSettings;
        }
        public FlightRecorderClientBase(HttpClient client, IOptions <AppSettings> settings, IHttpContextAccessor accessor, ICacheWrapper cache)
        {
            _cache = cache;

            // Configure the Http client
            _settings           = settings;
            _client             = client;
            _client.BaseAddress = new Uri(_settings.Value.ApiUrl);

            // Retrieve the token from session and create the authentication
            // header, if present
            string token = accessor.HttpContext.Session.GetString(LoginController.TokenSessionKey);

            if (!string.IsNullOrEmpty(token))
            {
                SetAuthenticationHeader(token);
            }
        }
Esempio n. 15
0
        public static T GetOrAdd <T>(this ICacheWrapper cache, string key, object locker, Func <T> func) where T : class
        {
            var result = cache[key] as T;

            if (result != null)
            {
                return(result);
            }
            lock (locker) {
                result = cache[key] as T;
                if (result != null)
                {
                    return(result);
                }
                result     = func.Invoke();
                cache[key] = result;
                return(result);
            }
        }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserService"/> class.
 /// </summary>
 public UserService(
     IUnitOfWork ufw,
     UserManager <User> userManager,
     RoleManager <Role> roleManager,
     IHttpContextAccessor accessor,
     IMapper mapper,
     IValidationLocalizer localizer,
     IIdentityAppSettings settings,
     ICacheWrapper cache)
 {
     _ufw         = ufw;
     _userManager = userManager;
     _roleManager = roleManager;
     _accessor    = accessor;
     _mapper      = mapper;
     _localizer   = localizer;
     _settings    = settings;
     _cache       = cache;
 }
Esempio n. 17
0
        public IntegrationService(ICacheWrapper appCache, CoudSuiteWebClient webClient, IProgressConnection connection, IProgressConfiguration progressConfiguration)
        {
            this._appCache              = appCache;
            this._connection            = connection;
            this._progressConfiguration = progressConfiguration;
            this._tokenObject           = ApplicationCookieUtilities.Principal(HttpContext.Current.User, out _);
            this._appCache.TokenObject  = this._tokenObject;

            _supportedRepositories = new Dictionary <string, SupportedRespository>
            {
                {
                    "icsw", new SupportedRespository {
                        IdmEntityType = "Item_Images", IdmRepository = "icsw", Formatter = "@Product_Number = \"{0}\""
                    }
                }
            };

            this._bearerToken = StringProtector.Unprotect(ApplicationCookieUtilities.BearerTokenValue(HttpContext.Current.User), new ProgressConfiguration().ApplicationEncryptKey,
                                                          new ProgressConfiguration().ApplicationEncryptIv);
        }
Esempio n. 18
0
 public AddSightingWizard(LocationClient locations,
                          FlightClient flights,
                          AirlineClient airlines,
                          ManufacturerClient manufacturers,
                          ModelClient models,
                          AircraftClient aircraft,
                          SightingClient sightings,
                          IOptions <AppSettings> settings,
                          ICacheWrapper cache,
                          IMapper mapper)
 {
     _locations     = locations;
     _flights       = flights;
     _airlines      = airlines;
     _manufacturers = manufacturers;
     _models        = models;
     _aircraft      = aircraft;
     _sightings     = sightings;
     _settings      = settings;
     _cache         = cache;
     _mapper        = mapper;
 }
        private static void Cache <TReturnType>(LOGI.Framework.Toolkit.OpenSource.AspectF.AspectF aspect, ICacheWrapper cacheResolver,
                                                string key, Action work, Func <TReturnType, TReturnType> foundInCache)
        {
            TReturnType cachedData = cacheResolver.Get <TReturnType>(key);

            if (cachedData == null)
            {
                GetListFromSource <TReturnType>(aspect, cacheResolver, key);
            }
            else
            {
                // Give caller a chance to shape the cached item before it is returned
                TReturnType cachedType = foundInCache(cachedData);
                if (cachedType == null)
                {
                    GetListFromSource <TReturnType>(aspect, cacheResolver, key);
                }
                else
                {
                    aspect.WorkDelegate = new Func <TReturnType>(() => cachedType);
                }
            }

            work();
        }
        public static LOGI.Framework.Toolkit.OpenSource.AspectF.AspectF CacheList <TItemType, TListType>(this LOGI.Framework.Toolkit.OpenSource.AspectF.AspectF aspect,
                                                                                                         ICacheWrapper cacheResolver, string listCacheKey, Func <TItemType, string> getItemKey)
            where TListType : IList <TItemType>, new()
        {
            return(aspect.Combine(work =>
            {
                var workDelegate = aspect.WorkDelegate as Func <TListType>;

                // Replace the actual work delegate with a new delegate so that
                // when the actual work delegate returns a collection, each item
                // in the collection is stored in cache individually.
                Func <TListType> newWorkDelegate = () =>
                {
                    if (workDelegate != null)
                    {
                        TListType collection = workDelegate();
                        foreach (TItemType item in collection)
                        {
                            string key = getItemKey(item);
                            cacheResolver.Save(key, item);
                        }
                        return collection;
                    }
                    return default(TListType);
                };
                aspect.WorkDelegate = newWorkDelegate;

                // Get the collection from cache or real source. If collection is returned
                // from cache, resolve each item in the collection from cache
                Cache <TListType>(aspect, cacheResolver, listCacheKey, work,
                                  cached =>
                {
                    // Get each item from cache. If any of the item is not in cache
                    // then discard the whole collection from cache and reload the
                    // collection from source.
                    var itemList = new TListType();
                    foreach (TItemType cachedItem in cached.Select(item => cacheResolver.Get <TItemType>(getItemKey(item))))
                    {
                        if (null != cachedItem)
                        {
                            itemList.Add(cachedItem);
                        }
                        else
                        {
                            // One of the item is missing from cache. So, discard the
                            // cached list.
                            return default(TListType);
                        }
                    }

                    return itemList;
                });
            }));
        }
        public static LOGI.Framework.Toolkit.OpenSource.AspectF.AspectF CacheRetry <TReturnType>(this LOGI.Framework.Toolkit.OpenSource.AspectF.AspectF aspect,
                                                                                                 ICacheWrapper cacheResolver,
                                                                                                 ILogger logger,
                                                                                                 string key)
        {
            return(aspect.Combine(work =>
            {
                try
                {
                    Cache <TReturnType>(aspect, cacheResolver, key, work, cached => cached);
                }
                catch (Exception x)
                {
                    logger.Error(x);
                    System.Threading.Thread.Sleep(1000);

                    //Retry
                    try
                    {
                        Cache <TReturnType>(aspect, cacheResolver, key, work, cached => cached);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        throw;
                    }
                }
            }));
        }
 public DataAccessTestStub(ICacheWrapper cache)
 {
     _cache = cache;
 }
 public static LOGI.Framework.Toolkit.OpenSource.AspectF.AspectF Cache <TReturnType>(this LOGI.Framework.Toolkit.OpenSource.AspectF.AspectF aspect,
                                                                                     ICacheWrapper cacheResolver, string key)
 {
     return(aspect.Combine(work => Cache <TReturnType>(aspect, cacheResolver, key, work, cached => cached)));
 }
Esempio n. 24
0
 public OpenIdConfigService(IPathHelper pathHelper, ICacheWrapper cache)
 {
     _pathHelper = pathHelper;
     _cache = cache;
 }
Esempio n. 25
0
 public WorkflowCacheService(ICacheWrapper cacheWrapper)
 {
     _cacheWrapper = cacheWrapper;
     InitCache();
 }
Esempio n. 26
0
 public DetailViewService(ICacheWrapper cacheWrapper, IViewModelConfigService viewModelConfigService, IDetailViewSettingManager detailViewSettingManager)
 {
     _cacheWrapper = cacheWrapper;
     _viewModelConfigService = viewModelConfigService;
     _detailViewSettingManager = detailViewSettingManager;
 }
Esempio n. 27
0
 public SearchService(IMovieDatabaseProxy movieDatabaseProxy, ICacheWrapper cacheWrapper)
 {
     this._movieDatabaseProxy = movieDatabaseProxy;
     this._cacheWrapper       = cacheWrapper;
 }
        private static void GetListFromSource <TReturnType>(LOGI.Framework.Toolkit.OpenSource.AspectF.AspectF aspect, ICacheWrapper cacheResolver,
                                                            string key)
        {
            var workDelegate = aspect.WorkDelegate as Func <TReturnType>;

            if (workDelegate != null)
            {
                TReturnType realObject = workDelegate();
                cacheResolver.Save(key, realObject);
                workDelegate = () => realObject;
            }
            aspect.WorkDelegate = workDelegate;
        }
Esempio n. 29
0
 public ManufacturerClient(HttpClient client, IOptions <AppSettings> settings, IHttpContextAccessor accessor, ICacheWrapper cache)
     : base(client, settings, accessor, cache)
 {
 }
 public AuthenticationClient(HttpClient client, IOptions <AppSettings> settings, IHttpContextAccessor accessor, ICacheWrapper cache)
     : base(client, settings, accessor, cache)
 {
 }
Esempio n. 31
0
 public ListViewService(ICacheWrapper cacheWrapper, IViewModelConfigService viewModelConfigService)
 {
     _cacheWrapper = cacheWrapper;
     _viewModelConfigService = viewModelConfigService;
 }
Esempio n. 32
0
 public ContractResolverFactory(ICacheWrapper cache, IUiFasade uiFasade)
 {
     _cache = cache;
     _uiFasade = uiFasade;
 }
Esempio n. 33
0
 /// <summary>
 ///
 /// </summary>
 public UnitOfWork(WebSshDbContext dbContext, ICacheWrapper cache)
 {
     _dbContext = dbContext;
     _cache     = cache;
 }
 public JsonFileEducationService()
 {
     CacheWrapper = new MemoryCacheWrapper <EducationDto>();
 }
Esempio n. 35
0
 public OrderRepository(bool isAdmin, int employeeId, ICacheWrapper cache, IConnectionFactory factory = null, ISqlWorker broker = null) : base(cache, factory, broker)
 {
     _isAdmin    = isAdmin;
     _employeeId = employeeId;
 }
Esempio n. 36
0
 public ViewModelConfigService(IViewModelConfigLoader loder, ICacheWrapper cacheWrapper)
 {
     _loder = loder;
     _cacheWrapper = cacheWrapper;
 }
Esempio n. 37
0
 public TaskController(IBaseControllerServiceFacade baseServiceFacade, ITaskService taskService, ICacheWrapper cacheWrapper)
     : base(baseServiceFacade)
 {
     _taskService = taskService;
     _cacheWrapper = cacheWrapper;
 }
Esempio n. 38
0
 public ReportService(IReportDataService reportDataService, ICacheWrapper cacheWrapper)
 {
     _reportDataService = reportDataService;
     _cacheWrapper = cacheWrapper;
 }
Esempio n. 39
0
 public FileNotFoundHandler(SiteSettings siteSettings, IMrCMSRoutingErrorHandler errorHandler, ICacheWrapper cacheWrapper)
 {
     _siteSettings = siteSettings;
     _errorHandler = errorHandler;
     _cacheWrapper = cacheWrapper;
 }
Esempio n. 40
0
 /// <summary>Initializes an instance of the <see cref="FacebookCache" /> class using the specified <paramref name="apiKey" /> and
 /// <see cref="ICacheWrapper" /> instance.</summary>
 /// <param name="apiKey">The API key of the application using the cache.</param>
 /// <param name="cache">An instance of <see cref="ICacheWrapper" /> used to abstract access to the cache object used by the application.</param>
 public FacebookCache(String apiKey, ICacheWrapper cache)
 {
     this.ApiKey = apiKey;
     this.InnerCache = cache;
 }
Esempio n. 41
0
 public SightingsSearchClient(HttpClient client, IOptions <AppSettings> settings, IHttpContextAccessor accessor, ICacheWrapper cache)
     : base(client, settings, accessor, cache)
 {
 }
Esempio n. 42
0
 public MenuService(IMenuLoader loder, IViewModelConfigService viewModelConfigService, ICacheWrapper cacheWrapper)
 {
     _loder = loder;
     _viewModelConfigService = viewModelConfigService;
     _cacheWrapper = cacheWrapper;
 }
Esempio n. 43
0
 /// <summary>
 ///
 /// </summary>
 public Repository(WebSshDbContext context, ICacheWrapper cache)
 {
     _dbContext = context;
     _cache     = cache;
 }
Esempio n. 44
0
 public CacheManager(ICacheWrapper cache)
 {
     _cache = cache;
 }
 public AircraftClient(HttpClient client, IOptions <AppSettings> settings, IHttpContextAccessor accessor, ICacheWrapper cache, ModelClient models)
     : base(client, settings, accessor, cache)
 {
     _models = models;
 }
Esempio n. 46
0
 public FileNotFoundHandler(SiteSettings siteSettings, IMrCMSRoutingErrorHandler errorHandler, ICacheWrapper cacheWrapper)
 {
     _siteSettings = siteSettings;
     _errorHandler = errorHandler;
     _cacheWrapper = cacheWrapper;
 }