static EntityMapperCacheItem GetEntityMapperCacheItem(string key, System.Reflection.Assembly assembly, IEnumerable <Type> types) { foreach (var t in types) { var et = t.BaseType.GetGenericArguments().SingleOrDefault(); var entityName = et.Name; if (entityName == key) { var e = new EntityMapperCacheItem(entityName) { Value = ReflectionMethod.CreateObject(assembly, t), Expire = DateTime.MaxValue, Type = CacheType.Application }; return(e); } } return(null); }
static async void TaskAsyncLoad(EntityMapperCacheManager cache, IEnumerable <Type> types) => await Task.Run(() => { foreach (var t in types) { var et = t.BaseType.GetGenericArguments().SingleOrDefault(); if (et != null) { var entityName = et.Name; if (!cache.ContainsKey(entityName)) { var e = new EntityMapperCacheItem(entityName) { Value = ReflectionMethod.CreateObject(cache._assembly, t), Expire = DateTime.MaxValue, Type = CacheType.Application }; cache.Add(e.Key, e); } } } });