如何在 MVVM Light ViewModelLocator 中使用参数实例化服务?

问题描述

我已经搜索了大约 3 个小时。 我需要知道如何使用由 MVVM Light 的 viewmodelLocator 中的另一个服务生成的参数来实例化一个服务。

在我的 viewmodelLocator 类中,我注册了我的视图模型,然后注册了它们使用的服务,如下所示:

        SimpleIoc.Default.Register<INetworkClient>(() => new NetworkClient());
        SimpleIoc.Default.Register<IapiclientAuthentication>(() => new apiclientAuthentication());
        SimpleIoc.Default.Register<Iapiclient>(() =>
        {
            INetworkClient networkClient = ServiceLocator.Current.GetInstance<INetworkClient>();
            return new apiclient(networkClient,new Uri("https://someuri.com/"),authResponse.AdminUserId,authResponse.ApiKey);
        });

问题是我传递给上面的 apiclient 的“authResponse”是通过调用实现 IapiclientAuthentication 的方法产生的结果(我也在上面的 IoC 容器中注册)。当我在上面创建 apiclient 时,该响应不可用。我该怎么办。

请至少把我推向正确的方向。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)