用于Unity的模拟GetExportedValues <t>

时间:2019-02-27 14:42:09

标签: c# .net unity-container mef

Unity依赖注入的模拟GetExportedValues​<T>(System.ComponentModel.Composition)是什么?

        private LoginView GetLoginView()
    {
        //Container => CompositionContainer
        var loginWindow = Container.GetExportedValues<IViewFor<ILoginViewModel>>().FirstOrDefault();
        if (loginWindow == null)
            throw new NullReferenceException($"Login Window can't be null");

        return (LoginView)loginWindow;
    }

0 个答案:

没有答案