/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { AddService(typeof(NanoDeviceCommService), CreateNanoDeviceCommService); // Need to add the View model Locator to the application resource dictionary programatically // because at the extension level we don't have 'XAML' access to it // try to find if the view model locator is already in the app resources dictionary if (System.Windows.Application.Current.TryFindResource("Locator") == null) { // instantiate the view model locator... ViewModelLocator = new ViewModelLocator(); // ... and add it there System.Windows.Application.Current.Resources.Add("Locator", ViewModelLocator); } ServiceLocator.Current.GetInstance <DeviceExplorerViewModel>().Package = this; // need to switch to the main thread to initialize the command handlers await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); DeviceExplorerCommand.Initialize(this, ViewModelLocator, await this.GetServiceAsync(typeof(NanoDeviceCommService)) as INanoDeviceCommService); DeployProvider.Initialize(this, ViewModelLocator); // Enable debugger UI context UIContext.FromUIContextGuid(CorDebug.EngineGuid).IsActive = true; await TaskScheduler.Default; ServiceLocator.Current.GetInstance <DeviceExplorerViewModel>().NanoDeviceCommService = await this.GetServiceAsync(typeof(NanoDeviceCommService)) as INanoDeviceCommService; await base.InitializeAsync(cancellationToken, progress); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // make sure "our" key exists and it's writeable s_instance.UserRegistryRoot.CreateSubKey(EXTENSION_SUBKEY, true); AddService(typeof(NanoDeviceCommService), CreateNanoDeviceCommServiceAsync); // Need to add the View model Locator to the application resource dictionary programmatically // because at the extension level we don't have 'XAML' access to it // try to find if the view model locator is already in the app resources dictionary if (System.Windows.Application.Current.TryFindResource("Locator") == null) { // instantiate the view model locator... ViewModelLocator = new ViewModelLocator(); // ... and add it there System.Windows.Application.Current.Resources.Add("Locator", ViewModelLocator); } SimpleIoc.Default.GetInstance <DeviceExplorerViewModel>().Package = this; await MessageCentre.InitializeAsync(this, "nanoFramework Extension"); await DeviceExplorerCommand.InitializeAsync(this, ViewModelLocator, await GetServiceAsync(typeof(NanoDeviceCommService)) as INanoDeviceCommService); DeployProvider.Initialize(this, ViewModelLocator); // Enable debugger UI context UIContext.FromUIContextGuid(CorDebug.EngineGuid).IsActive = true; await TaskScheduler.Default; SimpleIoc.Default.GetInstance <DeviceExplorerViewModel>().NanoDeviceCommService = await GetServiceAsync(typeof(NanoDeviceCommService)) as INanoDeviceCommService; OutputWelcomeMessage(); await base.InitializeAsync(cancellationToken, progress); }