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