1

果园缓存设计:

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);

但我在 Dryioc 找不到参数解决方案,在 Dryioc 怎么办?

4

1 回答 1

1

简短的回答:

container.Resolve<Func<Type, ICacheManager>>()(my parameter ...);
于 2016-07-07T13:32:34.853 回答