Beispiel #1
0
        public void Add <TValue>(bool saveAttribute, bool saveGet, bool saveSet, bool saveProperties)
        {
            string typeName = typeof(TValue).Name;

            PropertyInfo[] properties = typeof(TValue).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);

            if (saveGet && !CacheGet.ContainsKey(typeName))
            {
                CacheGet.Add(typeName, properties.ToDictionary(g => g.Name, m => CacheFacade.CreateFunction <TValue>(m)));
            }
            if (saveSet && !CacheSet.ContainsKey(typeName))
            {
                CacheSet.Add(typeName, properties.ToDictionary(s => s.Name, m => CacheFacade.CreateAction <TValue>(m)));
            }
            if (saveProperties && !CacheProperties.ContainsKey(typeName))
            {
                CacheProperties.Add(typeName, properties.ToDictionary(p => p.Name, p => p));
            }
            if (saveAttribute && !CacheAttribute.ContainsKey(typeName))
            {
                CacheAttribute.Add(typeName, new Dictionary <string, Dictionary <string, CustomAttributeTypedArgument> >(properties.Length));
                foreach (var property in properties)
                {
                    CachingAttribute(property, typeName);
                }
            }
        }
Beispiel #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);
        }
Beispiel #3
0
 public bool HasMethodGet() => CacheGet.Any();
Beispiel #4
0
 public async Task <bool> HasMethodGet(
     CancellationToken token) =>
 await Task.Run(() => CacheGet.Any(), token).
 ConfigureAwait(false);