public MainWindowViewModel() { _yupSettings = ContainerHelper.GetService <IYupSettings>();; _YuipsViewModel = ContainerHelper.GetService <YupisViewModel>(); _VideosViewModel = ContainerHelper.GetService <VideosViewModel>(); _ChannelsViewModel = ContainerHelper.GetService <ChannelsViewModel>(); _PlayerViewModel = ContainerHelper.GetService <PlayerViewModel>(); //_DashboardViewModel = ContainerHelper.GetService<DashboardViewModel>(); }
/// <summary> /// OnStartup override to initialize our DI class /// </summary> /// <param name="e"></param> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var cefSettings = new CefSharp.CefSettings { //PackLoadingDisabled = true }; cefSettings.CefCommandLineArgs.Add("disable-gpu", "1"); cefSettings.CefCommandLineArgs.Add("disable-gpu-vsync", "1"); Cef.Initialize(cefSettings); // Create our DI container and build it ContainerHelper.InitializeBuilder(); ContainerHelper.Builder.Register(c => new EventBus()).As <IEventBus>().SingleInstance(); ContainerHelper.Builder.Register(c => new YupSettings()).As <IYupSettings>().SingleInstance(); ContainerHelper.Builder.RegisterType <YupRepository>().As <IYupRepository>().SingleInstance(); ContainerHelper.Builder.RegisterType <YtManager>().As <IYtManager>(); ContainerHelper.Builder.Register(c => new HoldingBay()).As <IHoldingBay>().SingleInstance(); //TODO: Register players named ? ContainerHelper.Builder.RegisterType <FlashAxControl>().Named <IMediaPlayer>("youtube").SingleInstance(); //TODO: Think if we want to register ViewModel classes as singleton instances ?! ContainerHelper.Builder.RegisterType <VideosViewModel>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); ContainerHelper.Builder.RegisterType <YupisViewModel>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); ContainerHelper.Builder.RegisterType <PlayerViewModel>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); ContainerHelper.Builder.RegisterType <ChannelsViewModel>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); //TODO: Register all external services here ..... ContainerHelper.SetAutofacContainer(); var repository = ContainerHelper.GetService <IYupRepository>(); repository.LoadRepository(); var eventsReg = ContainerHelper.Container.Resolve <IEnumerable <IEventRegistrator> >(); foreach (IEventRegistrator eventRegistrator in eventsReg) { eventRegistrator.PublishEvents(); } foreach (IEventRegistrator eventRegistrator in eventsReg) { eventRegistrator.SubscribeEvents(); } var settings = ContainerHelper.GetService <IYupSettings>(); settings.checkAppFolderPath(); settings.loadAppSettings(); // Create our main window - since we removed startup URI YUP.App.MainWindow wnd = new MainWindow(); wnd.Show(); }