public static T CreateProxy <T>(this ICacheProxyGenerator generator, CreateProxyOptions options, params object[] additionalParameters) where T : class { if (generator == null) { throw new ArgumentNullException(nameof(generator)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } var args = new object[6 + additionalParameters.Length]; Array.Copy(additionalParameters, args, additionalParameters.Length); args[args.Length - 6] = options.CacheProviderFactory; args[args.Length - 5] = options.DistributedLockFactory; args[args.Length - 4] = options.KeyFormatter; args[args.Length - 3] = options.ValueSerializer; args[args.Length - 2] = options.StreamManager; args[args.Length - 1] = new OptionMonitorWrapper(options.Options); return((T)Activator.CreateInstance(generator.CreateProxyType(typeof(T)), args)); }
public static Type CreateProxyType <T>(this ICacheProxyGenerator generator) where T : class { if (generator == null) { throw new ArgumentNullException(nameof(generator)); } return(generator.CreateProxyType(typeof(T))); }
public static INetCacheBuilder AddNetCache(this IServiceCollection services, ICacheProxyGenerator generator, Action <CacheOptions>?configureAction = null) { if (configureAction != null) { services.Configure(configureAction); } services.AddSingleton(generator); services.TryAddSingleton(new RecyclableMemoryStreamManager()); var builder = new NetCacheBuilder(services, generator); builder.UseKeyFormatter <KeyFormatter>(); return(builder); }
public NetCacheBuilder(IServiceCollection services, ICacheProxyGenerator generator) { Services = services; Generator = generator; }