Beispiel #1
0
        private CacheOperationContext GetOperationContext(
            CacheOperation operation, MethodInfo method, Object[] args, Object target, Type targetType)
        {
            CacheOperationMetadata metadata = GetCacheOperationMetadata(operation, method, targetType);

            return(new CacheOperationContext(metadata, args, target));
        }
Beispiel #2
0
 public CacheOperationMetadata(CacheOperation operation, MethodInfo method, Type targeType, IKeyGenerator keyGenerator, ICacheResolver cacheResolver)
 {
     this.Operation     = operation;
     this.Method        = method;
     this.TargeType     = targeType;
     this.KeyGenerator  = keyGenerator;
     this.CacheResolver = cacheResolver;
 }
Beispiel #3
0
        public CacheOperationMetadata GetCacheOperationMetadata(CacheOperation operation, MethodInfo method, Type targetType)
        {
            var cacheKey = new CacheOperationCacheKey(operation, method, targetType);

            this.metadataCaches.TryGetValue(cacheKey, out var metadata);
            if (metadata == null)
            {
                IKeyGenerator keyGenerator;
                var           keyGeneratorName = operation.KeyGenerator;
                if (keyGeneratorName.HasText())
                {
                    keyGenerator = this._serviceProvider.GetServiceByName <IKeyGenerator>(keyGeneratorName);
                }
                else
                {
                    keyGenerator = new SimpleKeyGenerator();
                }

                ICacheResolver cacheResolver;
                var            cacheResolverName = operation.CacheResolver;
                if (cacheResolverName.HasText())
                {
                    cacheResolver = this._serviceProvider.GetServiceByName <ICacheResolver>(cacheResolverName);
                }
                else if (operation.CacheManager.HasText())
                {
                    ICacheManager cacheManager =
                        this._serviceProvider.GetServiceByName <ICacheManager>(operation.CacheManager);

                    SbAssert.NotNull(cacheManager, "cacheManager:" + operation.CacheManager + " Not Exist");

                    cacheResolver = new SimpleCacheResolver(cacheManager);
                }
                else
                {
                    cacheResolver = new SimpleCacheResolver();
                }

                metadata = new CacheOperationMetadata(operation, method, targetType, keyGenerator, cacheResolver);
            }

            return(metadata);
        }
 public CacheOperationCacheKey(CacheOperation cacheOperation, MethodInfo method, Type targetType)
 {
     this._cacheOperation = cacheOperation;
     this._attributeKey   = new AttributeKey(method, targetType);
 }