Ejemplo n.º 1
0
        private static void RegisterStaticCache(FieldInfo field)
        {
            var attribute  = (PeekInCacheAttribute)field.GetCustomAttribute(typeof(PeekInCacheAttribute));
            var classCache = field.GetValue(null);

            CacheRefernceStore.Register(attribute.CacheName, classCache);
        }
Ejemplo n.º 2
0
        private static void RegisterAspNetCoreDefaultMemoryCache(FieldInfo field)
        {
            var attribute  = (PeekInCacheAttribute)field.GetCustomAttribute(typeof(PeekInCacheAttribute));
            var classCache = new PlaceholderMemoryCache(attribute.CacheName);

            CacheRefernceStore.Register(attribute.CacheName, classCache);
        }
Ejemplo n.º 3
0
        public static IServiceCollection PeekInAClass(
            this IServiceCollection service, Type classType)
        {
            var classFields = classType.GetRuntimeFields()
                              .Where(x => x.GetCustomAttribute <PeekInCacheAttribute>() != null).ToArray();

            foreach (var field in classFields)
            {
                var attribute  = (PeekInCacheAttribute)field.GetCustomAttribute(typeof(PeekInCacheAttribute));
                var classCache = field.GetValue(null);
                CacheRefernceStore.Register(attribute.CacheName, classCache);
            }
            return(service);
        }