2016-07-07 69 views
1

果园缓存设计:从Autofac迁移如何解决?

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

但我cant'find在使用参数解析dryioc,dryioc怎么样?

+0

欢迎堆栈溢出!我编辑了你的问题来格式化你的代码示例,以便正确渲染 - 请参阅编辑帮助以获取更多格式化信息。请编辑以提供确定具体问题所需的其他详细信息。祝你好运! – Wtower

回答

1

简短的回答:

container.Resolve<Func<Type, ICacheManager>>()(my parameter ...); 
+0

没关系,谢谢! – try

+0

我会把它留在这里...也许这可能有助于其他人跟踪状态:https://bitbucket.org/dadhi/dryioc/issues/304/add-option-to-pass-values-for-some – Maxim