예제 #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);
                }
            }
        }
예제 #2
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);
        }
예제 #3
0
 public bool HasProperty() => CacheProperties.Any();
예제 #4
0
 public async Task <bool> HasProperty(
     CancellationToken token) =>
 await Task.Run(() => CacheProperties.Any(), token).
 ConfigureAwait(false);