2017-03-20 60 views
2

MVVLight當我註冊的意見車型我做註銷的ViewModels在註銷

SimpleIoc.Default.Register(
    () => SimpleIoc.Default.GetInstanceWithoutCaching<INewsViewModel>(), 
    flow.Guid.ToString()); 

ViewModelsCache.Instance.AddViewModelInfo(flow.Guid.ToString(), INewsViewModel); 

我退出,我試圖做後:

foreach (var viewModelInfo in ViewModelsCache.Instance.ViewModelsInfo) 
{ 
    Type type = viewModelInfo.Value.GetType();    
    SimpleIoc.Default.Unregister<type>(viewModelInfo.key); 
} 

但我得到的錯誤:

'type' is a variable but is used like a type

您有其他建議嗎?

+1

我在想你爲什麼要取消註冊ViewModels?否則,你可以找到你的問題的答案 - > http://stackoverflow.com/questions/1408120/how-to-call-generic-method-with-a-given-type-object – EvZ

回答

0

如何取消註冊所有實例?

SimpleIoc.Default.Reset();