private void RemoveSettingsProvider(WorkItem workItem, FrameworkElement frameworkElement) { Type providerType = FrameworkElementStrategySettings.GetSettingsProviderType(frameworkElement); if (providerType != null) { if (!string.IsNullOrEmpty(frameworkElement.Name)) { IUXSettingsService settingsService = workItem.Services.Get <IUXSettingsService>(); settingsService.RemoveProvider(frameworkElement); } } }
private void AddSettingsProvider(WorkItem workItem, FrameworkElement frameworkElement) { Type providerType = FrameworkElementStrategySettings.GetSettingsProviderType(frameworkElement); if (providerType != null) { if (!string.IsNullOrEmpty(frameworkElement.Name)) { IUXSettingsService settingsService = workItem.Services.Get <IUXSettingsService>(); ISettingsProvider provider = Activator.CreateInstance(providerType) as ISettingsProvider; settingsService.AddProvider(frameworkElement, provider); } } }
protected override void AddServices() { base.AddServices(); RootWorkItem.Services.Add <IUserSessionService>(_userSessionService); if (_userSessionService.ActivationUri != null) { ShellHyperlink hyperlink = HyperlinkService.ConvertToShellHyperlink(_userSessionService.ActivationUri); if (hyperlink.Data.ContainsKey("ModuleId")) { //Add shellhyperlink to workitem to prevent dialogs being lodad before the module is fully loaded. See NavigationBarView.xaml.cs function NavigationBarSelectionChangedEventHandler //Hyperlink is removed from workitem in HyperlinkService.cs function ExecuteHyperlink(ShellHyperlink hyperlink) RootWorkItem.Items.Add(hyperlink); } } if (string.IsNullOrEmpty(_userSessionService.DomainUser)) { _userSessionService.UserId = string.Format("{0}\\{1}", Environment.UserDomainName, Environment.UserName); } else { _userSessionService.Password = _password; } RootWorkItem.Items.Add(_tokenCache); IChannelFactoryService factoryService = ServiceActivator.CreateInstance <IChannelFactoryService>(_userSessionService, _tokenCache); RootWorkItem.Services.Add <IChannelFactoryService>(factoryService); IAuthorizationService authorizationService = ServiceActivator.CreateInstance <IAuthorizationService>(); RootWorkItem.Services.Add <IAuthorizationService>(authorizationService); IFavoritesService favoritesService = RootWorkItem.Services.AddNew <FavoritesService, IFavoritesService>(); RootWorkItem.Services.AddNew <ShellModuleService, IShellModuleService>(); RootWorkItem.Services.AddNew <FileService, IFileService>(); _settingsService = ServiceActivator.CreateInstance <IUXSettingsService>(ContainerName); RootWorkItem.Services.Add <IUXSettingsService>(_settingsService); RootWorkItem.Services.AddNew <HyperlinkService, IHyperlinkService>(); ThreadPool.QueueUserWorkItem((e) => { try { _settingsService.LoadSettings(); favoritesService.LoadFavorites(); } catch (Exception) { } _settingsLoadedEvent.Set(); }); }