public T CreateProxy <T>(ConfigurationForType configurationForType, params object[] parameters) where T : class { var target = createTarget(configurationForType.ComponentType.ConcreteType, parameters); var interceptor = new CacheInterceptor(_cache, configurationForType, target); return(proxyFactory.CreateProxy <T>(interceptor, typeof(ICachingComponent))); }
public CacheInterceptor(CacheAdapter cache, ConfigurationForType configurationForType, object target) { _cache = cache; _configurationForType = configurationForType; _target = target; _cachingComponent = new CachingComponent(cache, configurationForType.CacheKey, configurationForType); }
public FluentBuilder(CacheBuilder cacheBuilder, IDictionary <Type, ConfigurationForType> cachedMethods, ConfigurationForType details) { _cacheBuilder = cacheBuilder; _cachedMethods = cachedMethods; _details = details; }
public FluentBuilder(CacheBuilder cacheBuilder, IDictionary <Type, ConfigurationForType> cachedMethods, ConfigurationForType details, ProxyValidator proxyValidator) { _cacheBuilder = cacheBuilder; _cachedMethods = cachedMethods; _details = details; _proxyValidator = proxyValidator; }
/// <summary> /// Creates a caching component for <see cref="T"/>. /// </summary> /// <param name="typeAsCacheKey"> /// Gives a name to this type to be used as cache key. /// </param> /// <typeparam name="T"></typeparam> /// <returns></returns> public IFluentBuilder <T> For <T>(string typeAsCacheKey) { var concreteType = typeof(T); var details = new ConfigurationForType(concreteType, typeAsCacheKey); _details.Add(details); var fluentBuilder = new FluentBuilder <T>(this, _configuredTypes, details, _proxyValidator); return(fluentBuilder); }
public CacheInterceptor(CacheAdapter cache, ICacheKey cacheKey, ILockObjectGenerator lockObjectGenerator, ConfigurationForType configurationForType) { _cache = cache; _cacheKey = cacheKey; _lockObjectGenerator = lockObjectGenerator; _configurationForType = configurationForType; }
public T CreateProxyWithTarget <T>(T uncachedComponent, ConfigurationForType configurationForType) where T : class { var cacheInterceptor = new CacheInterceptor(_cache, configurationForType); var options = new ProxyGenerationOptions(new CacheProxyGenerationHook(configurationForType.CachedMethods)); options.AddMixinInstance(createCachingComponent(configurationForType)); return(typeof(T).IsClass ? generator.CreateClassProxyWithTarget(uncachedComponent, options, cacheInterceptor) : generator.CreateInterfaceProxyWithTarget(uncachedComponent, options, cacheInterceptor)); }
public CacheInterceptor(CacheAdapter cache, ICacheKey cacheKey, ILockObjectGenerator lockObjectGenerator, ConfigurationForType configurationForType, object target) { _cache = cache; _cacheKey = cacheKey; _lockObjectGenerator = lockObjectGenerator; _configurationForType = configurationForType; _target = target; _cachingComponent = new CachingComponent(cache, cacheKey, configurationForType); }
public T CreateProxy <T>(ConfigurationForType configurationForType, params object[] parameters) where T : class { var type = typeof(T); var cacheInterceptor = new CacheInterceptor(_cache, configurationForType); var options = new ProxyGenerationOptions(new CacheProxyGenerationHook(configurationForType.CachedMethods)); options.AddMixinInstance(createCachingComponent(configurationForType)); try { if (type.IsClass) { return((T)generator.CreateClassProxy(configurationForType.ComponentType.ConcreteType, options, parameters, cacheInterceptor)); } var target = Activator.CreateInstance(configurationForType.ComponentType.ConcreteType, parameters); return(generator.CreateInterfaceProxyWithTarget((T)target, options, cacheInterceptor)); } catch (MissingMethodException createInstanceEx) { throw new ArgumentException("Cannot instantiate proxy", createInstanceEx); } }
public CacheInterceptor(CacheAdapter cache, ConfigurationForType configurationForType) { _cache = cache; _configurationForType = configurationForType; }
public T CreateProxyWithTarget <T>(T uncachedComponent, ConfigurationForType configurationForType) where T : class { var interceptor = new CacheInterceptor(_cache, configurationForType, uncachedComponent); return(proxyFactory.CreateProxy <T>(interceptor, typeof(ICachingComponent))); }
public CacheProxyGenerationHook(ConfigurationForType methodData) { _methodData = methodData; }
private ICachingComponent createCachingComponent(ConfigurationForType configurationForType) { return(new CachingComponent(_cache, configurationForType.CacheKey, configurationForType)); }
public T CreateProxyWithTarget <T>(T uncachedComponent, ConfigurationForType configurationForType) where T : class { throw new System.NotImplementedException(); }
public T CreateProxy <T>(ConfigurationForType configurationForType, params object[] parameters) where T : class { throw new NotSupportedException("This test creates proxies. Please derive from " + typeof(FullTest).Name + " instead."); }
public T CreateProxyWithTarget <T>(T uncachedComponent, ConfigurationForType configurationForType) where T : class { throw new NotSupportedException("This test creates proxies. Please derive from " + typeof(FullTest).Name + " instead."); }
public T CreateProxy <T>(ConfigurationForType configurationForType, params object[] parameters) where T : class { throw new System.NotImplementedException(); }