Exemplo n.º 1
0
        public async Task AddProperty <TValue>(
            CancellationToken token)
        {
            await CacheFacade.RunActionInSemaphore(() =>
            {
                var values = GetValues <TValue>();

                var valid = CacheProperties.ContainsKey(values.typeName);

                if (valid || !values.isCacheable)
                {
                    return;
                }

                CacheProperties.Add(values.typeName, values.properties.ToDictionary(p => p.Name, p => p));
            }, token).ConfigureAwait(false);
        }
Exemplo n.º 2
0
        public async Task AddGet <TValue>(
            CancellationToken token)
        {
            await CacheFacade.RunActionInSemaphore(() =>
            {
                var values = GetValues <TValue>();

                var valid = CacheGet.ContainsKey(values.typeName);

                if (valid || !values.isCacheable)
                {
                    return;
                }

                var dictionary = values.properties.
                                 ToDictionary(g => g.Name, m => CacheFacade.CreateFunction <TValue>(m));
                CacheGet.Add(values.typeName, dictionary);
            }, token).ConfigureAwait(false);
        }
Exemplo n.º 3
0
        public async Task AddSet <TValue>(
            CancellationToken token)
        {
            await CacheFacade.RunActionInSemaphore(() =>
            {
                var(typeName, properties, isCacheable) = GetValues <TValue>();

                var valid = CacheSet.ContainsKey(typeName);

                if (valid || !isCacheable)
                {
                    return;
                }

                var dictionary = properties.
                                 ToDictionary(s => s.Name, m => CacheFacade.CreateAction <TValue>(m));

                CacheSet.Add(typeName, dictionary);
            }, token).ConfigureAwait(false);
        }
Exemplo n.º 4
0
        public async Task AddAttribute <TValue>(
            CancellationToken token)
        {
            await CacheFacade.RunActionInSemaphore(() =>
            {
                var values = GetValues <TValue>();

                var valid = CacheAttribute.ContainsKey(values.typeName);

                if (valid || !values.isCacheable)
                {
                    return;
                }

                var dictionary = new Dictionary <string, Dictionary <string, CustomAttributeTypedArgument> >(values.properties.Count());

                CacheAttribute.Add(values.typeName, dictionary);

                foreach (var property in values.properties)
                {
                    SetCacheAttributes(property, values.typeName);
                }
            }, token).ConfigureAwait(false);
        }