Files
29WxOrder/Main.Test/App.xaml.cs
T
2026-08-31 16:28:23 +08:00

58 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Main.Test.ViewModels;
using Main.Test.Views;
using MAX.Core.DependencyInjection;
using MAX.Core.Logger;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Mvvm;
using System.Configuration;
using System.Data;
using System.Windows;
using Trade.Framework;
using Trade.Framework.Extensions;
using Trade.Framework.Services;
namespace Main.Test;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : FrameworkApplication
{
public IScopedProvider CurrentScope => throw new NotImplementedException();
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
}
protected override Window CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// 严格模式:FrameworkApplication 已关闭 DryIoc 按需动态注册(WithConcreteTypeDynamicRegistrations),
// 所有被解析的类型必须显式注册,否则抛 ContainerException。
// 启动 Shell
containerRegistry.Register<MainWindow>();
// 窗口/控件 ViewModel(DISource 从容器解析)
containerRegistry.Register<MainViewModel>();
containerRegistry.Register<HeaderViewModel>();
// 对话框:RegisterDialog 只注册 View 本身,VM 由 ViewModelLocator 从容器解析,需单独注册
containerRegistry.RegisterDialog<bbbDialogView, bbbDialogViewModel>(nameof(bbbDialogView));
containerRegistry.Register<bbbDialogViewModel>();
// 服务:原先靠 DryIoc 动态注册(Transient),显式注册保持同样行为
//containerRegistry.Register<UserManager>();
// 若希望 UserManager 全局只实例化一次:
// containerRegistry.RegisterSingleton<UserManager>();
//containerRegistry.RegisterSingleton<ILoggerFacade, ConsoleLogger>();
}
}