Esempio n. 1
0
 private T RecuperarDoCache <T, ID>(CacheMemoria <T, ID> cache, ID id, bool forcarAtualizacao)
     where T : class, new()
 {
     return(forcarAtualizacao
         ? null
         : cache.RecuperarDoCache(id));
 }
Esempio n. 2
0
        /// <summary>
        /// Recupera um item a partir do cache, se existir. Caso não exista, cria um mecanismo para recuperação do
        /// dado a partir do banco e depois atualiza o cache.
        /// </summary>
        protected Lazy <T> ObterUsandoCache <T, ID>(CacheMemoria <T, ID> cache, ID id, Func <T> recuperarDoBanco,
                                                    bool forcarAtualizacao = false)
            where T : class, new()
        {
            T itemCache = RecuperarDoCache(cache, id, forcarAtualizacao);

            if (itemCache != null)
            {
                return(new Lazy <T>(() => itemCache));
            }

            return(new Lazy <T>(() =>
            {
                itemCache = RecuperarDoCache(cache, id, forcarAtualizacao);

                if (itemCache == null)
                {
                    try
                    {
                        itemCache = recuperarDoBanco() ?? new T();
                    }
                    catch
                    {
                        itemCache = new T();
                    }

                    cache.AtualizarItemNoCache(itemCache, id);
                }

                return itemCache;
            }));
        }
Esempio n. 3
0
 static ClienteDTO()
 {
     cacheDadosCliente = new CacheMemoria <DadosCliente, uint>("dadosCliente");
 }
Esempio n. 4
0
 static DadosChapaVidroDTO()
 {
     cacheChapasVidro = new CacheMemoria <ChapaVidro, uint>("chapasVidro");
 }
Esempio n. 5
0
 static DadosAmbienteDTO()
 {
     cacheAmbientes = new CacheMemoria <List <IAmbienteCalculo>, string>("cacheAmbientes");
 }
Esempio n. 6
0
 static DadosGrupoSubgrupoDTO()
 {
     cacheGrupos    = new CacheMemoria <GrupoProd, int>("cacheGrupos");
     cacheSubgrupos = new CacheMemoria <SubgrupoProd, int>("cacheSubgrupos");
 }
Esempio n. 7
0
 static DadosProdutoDTO()
 {
     cacheProdutos = new CacheMemoria <Produto, int>("produtos");
     cacheDescontosAcrescimosCliente = new CacheMemoria <DescontoAcrescimoCliente,
                                                         KeyValuePair <uint, uint?> >("descontosAcrescimosCliente");
 }
 static BaseCadastroAtualizacaoDto()
 {
     CACHE_CONVERSORES = new CacheMemoria <object, string>("cacheConversores", 10);
 }
Esempio n. 9
0
 static RecalcularOrcamento()
 {
     cacheOrcamentos = new CacheMemoria <Data.Model.Orcamento, string>("orcamentos");
 }
Esempio n. 10
0
 static DadosBaixaEstoqueDTO()
 {
     cacheProdutosBaixaEstoque = new CacheMemoria <List <ProdutoBaixaEstoque>, int>("produtosBaixaEstoque");
 }
Esempio n. 11
0
 static GenericBenef()
 {
     cacheBeneficiamentos = new CacheMemoria <BenefConfig, uint>("beneficiamentos");
 }