public PrincipalTenancyContextProvider()
        {
            try
            {
                _log = ClassLogger.Create(this.GetType());
                this.principalContextProvider =
                    (Catalog.Factory.Resolve <IContextProvider>(
                         PrincipalTenancyContextProviderConfiguration.PrincipalContextFactoryKey)
                     ?? Catalog.Factory.Resolve <IContextProvider>("TenancyContext"))
                    ?? Catalog.Factory.Resolve <IContextProvider>();
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    _log.Error(ex.ToString() + " \n InnerException: " + ex.InnerException.ToString());
                }
                else
                {
                    _log.Error(ex.ToString());
                }
                Console.WriteLine(ex.ToString());
            }

            this.cachedTenancies =
                Catalog.Preconfigure().Add(CachedDataLocalConfig.OptionalMaximumCacheSize, 5000).Add(
                    CachedDataLocalConfig.OptionalGroomExpiredData, true).Add(
                    CachedDataLocalConfig.OptionalDefaultExpirationTimeSeconds, 600).Add(
                    CachedDataLocalConfig.OptionalCacheHitRenewsExpiration, true).ConfiguredCreate(
                    () => new InMemoryCachedData <string, string>());
        }
 static BlobFileDownload()
 {
     _cache = new InMemoryCachedData <string, Stream>();
     _cache.MaximumCacheItemsCount = 500;
     _cache.DefaultExpireTime      = new TimeSpan(0, 1, 0);
     _cache.RenewOnCacheHit        = true;
     _cache.DisposeOfData          = true;
 }
示例#3
0
 static ContextualAuthorization()
 {
     _cachedPrincipals = Catalog.Preconfigure()
                         .Add(CachedDataLocalConfig.OptionalMaximumCacheSize, 5000)
                         .Add(CachedDataLocalConfig.OptionalGroomExpiredData, true)
                         .Add(CachedDataLocalConfig.OptionalDefaultExpirationTimeSeconds, 600)
                         .Add(CachedDataLocalConfig.OptionalCacheHitRenewsExpiration, true)
                         .ConfiguredCreate(() => new InMemoryCachedData <string, ApplicationPrincipal>());
 }
        public void SetUp()
        {
            fakeCachedData      = new FakeCachedData();
            fakeDataService     = new FakeDataService();
            fakeStoryRepository = new FakeStoryRepository(fakeDataService);
            storyController     = new StoryController(fakeStoryRepository, fakeCachedData);

            fakePageIndex = "0";
            fakeSize      = "10";
        }
示例#5
0
        public ManageAccountsViewModel(ITradesContext tradesContext, IUpdateCachedData <Account> updateCachedData, ICachedData <Account> cachedData)
        {
            _tradesContext    = tradesContext;
            _updateCachedData = updateCachedData;
            _cachedData       = cachedData;

            _editAccountViewModel = new EditAccountViewModel(_tradesContext, _updateCachedData, _cachedData);
            _newAccountViewModel  = new NewAccountViewModel(_tradesContext);

            NewAccountVM.NewAccountAdd += EditAccountVM.OnNewAccountAdd;
        }
示例#6
0
        internal void Delete(Type dtoType, int id)
        {
            // при удалении на сервере удалить из внутреннего кеша
            Task <HttpStatusCode> t = _client.DeleteAsync(dtoType, id);

            t.ContinueWith(td =>
            {
                if (td.Result != HttpStatusCode.Accepted)
                {
                    return;
                }
                if (_dataSources.ContainsKey(dtoType))
                {
                    ICachedData items = _dataSources[dtoType];
                    items.Delete(id);
                }
            });
        }
示例#7
0
        internal void Update(BaseDTO dto)
        {
            // при изменении на сервере, изменить в кеше
            Task <BaseDTO> t = _client.UpdateAsync(dto);

            t.ContinueWith(td =>
            {
                BaseDTO dtoFromServer = td.Result as BaseDTO;
                if (IfErrorShowMessage(dtoFromServer))
                {
                    return;
                }
                if (_dataSources.ContainsKey(dto.GetType()))
                {
                    ICachedData items = _dataSources[dto.GetType()];
                    items.Update(dto);
                }
            });
        }
        public AzureBlobImageStorage()
        {
            _log   = ClassLogger.Create(GetType());
            _dblog = DebugOnlyLogger.Create(_log);

            var config              = Catalog.Factory.Resolve <IConfig>(SpecialFactoryContexts.Routed);
            var maxCacheSize        = config.Get <int>(ImageStorageLocalConfig.CacheSize);
            var hitRenewsExpiration = config.Get <bool>(ImageStorageLocalConfig.CacheHitRenewsExpiration);
            var minutes             = config.Get(ImageStorageLocalConfig.OptionalExpirationTimeMinutes, 60);
            var expirationLife      = TimeSpan.FromMinutes(minutes);

            _containerName = config[ImageStorageLocalConfig.ContainerName];

            _cache = Catalog.Preconfigure()
                     .Add(CachedDataLocalConfig.OptionalCacheHitRenewsExpiration, hitRenewsExpiration)
                     .Add(CachedDataLocalConfig.OptionalDefaultExpirationTimeSeconds, expirationLife)
                     .Add(CachedDataLocalConfig.OptionalGroomExpiredData, true)
                     .Add(CachedDataLocalConfig.OptionalMaximumCacheSize, maxCacheSize)
                     .ConfiguredResolve <ICachedData <string, byte[]> >(DurabilityFactoryContexts.Volatile);

            _bc = Client.FromConfig().ForBlobs();
        }
示例#9
0
        internal void Create(BaseDTO dto)
        {
            Task <BaseDTO> t = _client.CreateObjectAsync(dto);

            t.ContinueWith(td =>
            {
                BaseDTO dtoFromServer = td.Result as BaseDTO;
                if (IfErrorShowMessage(dtoFromServer))
                {
                    return;
                }
                if (_dataSources.ContainsKey(dto.GetType()))
                {
                    ICachedData items = _dataSources[dto.GetType()];
                    items.Add(dto);
                }
                else
                {
                    ICachedData cache = new CacheCollection <BaseDTO>();
                    cache.Add(td.Result);
                    _dataSources.Add(dto.GetType(), cache);
                }
            });
        }
示例#10
0
 public static IQueryable <ClosedTrade> ForCurrentAccount(this DbSet <ClosedTrade> closedTrades, ICachedData <Account> cached)
 => closedTrades.Where(t => t.AccountId == cached.CurrentAccount.Id);
 /// <summary>
 /// Constructor injection
 /// </summary>
 /// <param name="cachedData"></param>
 public WeatherForcastRepository(ICachedData cachedData)
 {
     _cachedData = cachedData;
 }
示例#12
0
 public ExternalDataManager(ICachedData <Account> curAccount, IMapper mapper, ICsv csv)
 {
     _curAccount = curAccount;
     _mapper     = mapper;
     _csv        = csv;
 }
 public CurrentAccountTradeContext(ITradesContext context, ICachedData <Account> curAccountCache)
 {
     _context         = context;
     _curAccountCache = curAccountCache;
 }
示例#14
0
 /// <summary>
 /// Constructor injection
 /// </summary>
 /// <param name="cachedData">Object to inject</param>
 public CachedData(ICachedData cachedData)
 {
     _cache = cachedData;
 }
示例#15
0
 public Passmark(ICachedData cachedData)
 {
     _cachedData = cachedData;
 }
示例#16
0
 public TodoListsRepository(ICachedData cachedData)
 {
     _cachedData = cachedData;
 }
示例#17
0
 public void PassmarkTest()
 {
     _fileops    = Substitute.For <IFileOperations>();
     _cachedData = Substitute.For <ICachedData>();
 }
 public ListResultViewComponent(ICachedData cachedData, [FromServices] Microsoft.AspNetCore.Identity.UserManager <ApplicationUser> userManager)
 {
     data             = cachedData;
     this.userManager = userManager;
 }
 public StoryController(IStoryRepository storyRepository, ICachedData serviceCachedData)
 {
     _storyRepository   = storyRepository;
     _serviceCachedData = serviceCachedData;
 }