Orchard缓存设计:
public interface ICacheManager
{
ICache<TKey, TResult> GetCache<TKey, TResult>();
}
class DefaultCacheManager : ICacheManager
{
public DefaultCacheManager(Type component, ICacheHolder cacheHolder)
{
//do something
}
public ICache<TKey, TResult> GetCache<TKey, TResult>()
{
//do somthing
}
}
Autofac代码:
//1.register
builder.RegisterType<DefaultCacheManager>().As<ICacheManager>().SingleInstance();
//2.reslove
// the parameter is dynamic
var parameter = new TypedParameter(do somthing...);
container.Resolve(parameter); //resolve by parameter
问题:
Autofac有一个方法:
object Resolve(Type serviceType, params Parameter[] parameters);
但我不能在干燥处找到params的决心,干how怎么办?
答案 0 :(得分:1)
简短回答:
container.Resolve<Func<Type, ICacheManager>>()(my parameter ...);