using FlyADBase; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Unity; namespace Flyad7_WPF { public class UnityExt { public static UnityContainer Container; static UnityExt() { Init(); } static void Init() { Container = new UnityContainer(); Container.RegisterType<DebugAppParam>( new Unity.Lifetime.ContainerControlledLifetimeManager()); Container.RegisterFactory<FlyAD7>((unity) => { IFlyADClient flyAd = new FlyAD7(); var param = unity.Resolve<DebugAppParam>(); Misc.BindingOperations.SetBinding(param, "HasCRC", flyAd, "HasCRC"); return flyAd; }, new Unity.Lifetime.ContainerControlledLifetimeManager()); Container.RegisterFactory<AutoForwBackw>((unity) => { var flyad = Container.Resolve<FlyAD7>(); AutoForwBackw autofb = new AutoForwBackw(flyad); var param = unity.Resolve<DebugAppParam>(); Misc.BindingOperations.SetBinding(param, "FB_Pos1", autofb, "FB_Pos1", Misc.BindingOperations.BindingMode.TwoWay); Misc.BindingOperations.SetBinding(param, "FB_Pos2", autofb, "FB_Pos2", Misc.BindingOperations.BindingMode.TwoWay); return autofb; }, new Unity.Lifetime.ContainerControlledLifetimeManager()); Container.RegisterType<FlyADClientUI>( new Unity.Lifetime.ContainerControlledLifetimeManager()); Container.RegisterType<AutoGetGridAdv>( new Unity.Lifetime.ContainerControlledLifetimeManager()); Container.RegisterType<AutoSync>( new Unity.Lifetime.ContainerControlledLifetimeManager()); Container.RegisterFactory<GridAdvVm>((unity) => { var flyad = Container.Resolve<FlyAD7>(); GridAdvVm gridAdvVm = new GridAdvVm(flyad); var param = unity.Resolve<DebugAppParam>(); Misc.BindingOperations.SetBinding(param, "HasGridAdv", gridAdvVm, "HasGridAdv", Misc.BindingOperations.BindingMode.TwoWay); return gridAdvVm; }, new Unity.Lifetime.ContainerControlledLifetimeManager()); } } }