/// <inheritdoc/> public override void Unapply(AppEntry appEntry, bool machineWide) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } #endregion var dispatcher = new PerTypeDispatcher <Capability>(ignoreMissing: true); if (WindowsUtils.IsWindows) { dispatcher.Add((Store.Model.Capabilities.FileType fileType) => Windows.FileType.Unregister(fileType, machineWide)); dispatcher.Add((Store.Model.Capabilities.UrlProtocol urlProtocol) => Windows.UrlProtocol.Unregister(urlProtocol, machineWide)); dispatcher.Add((Store.Model.Capabilities.AutoPlay autoPlay) => Windows.AutoPlay.Unregister(autoPlay, machineWide)); dispatcher.Add((ComServer comServer) => Windows.ComServer.Unregister(comServer, machineWide)); if (machineWide || WindowsUtils.IsWindows8) { dispatcher.Add((AppRegistration appRegistration) => Windows.AppRegistration.Unregister(appRegistration, machineWide)); } if (machineWide) { dispatcher.Add((Store.Model.Capabilities.DefaultProgram defaultProgram) => Windows.DefaultProgram.Unregister(defaultProgram)); } } else if (UnixUtils.IsUnix) { dispatcher.Add((Store.Model.Capabilities.FileType fileType) => Unix.FileType.Unregister(fileType, machineWide)); dispatcher.Add((Store.Model.Capabilities.UrlProtocol urlProtocol) => Unix.UrlProtocol.Unregister(urlProtocol, machineWide)); dispatcher.Add((Store.Model.Capabilities.DefaultProgram defaultProgram) => Unix.DefaultProgram.Unregister(defaultProgram, machineWide)); } dispatcher.Dispatch(appEntry.CapabilityLists.CompatibleCapabilities()); }
/// <inheritdoc/> public override void Apply(AppEntry appEntry, Feed feed, ITaskHandler handler, bool machineWide) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } #endregion var capabilities = appEntry.CapabilityLists.CompatibleCapabilities().ToList(); var target = new FeedTarget(appEntry.InterfaceUri, feed); var dispatcher = new PerTypeDispatcher <Capability>(ignoreMissing: true); if (WindowsUtils.IsWindows) { dispatcher.Add((Store.Model.Capabilities.FileType fileType) => Windows.FileType.Register(target, fileType, machineWide, handler)); dispatcher.Add((Store.Model.Capabilities.UrlProtocol urlProtocol) => Windows.UrlProtocol.Register(target, urlProtocol, machineWide, handler)); dispatcher.Add((Store.Model.Capabilities.AutoPlay autoPlay) => Windows.AutoPlay.Register(target, autoPlay, machineWide, handler)); dispatcher.Add((ComServer comServer) => Windows.ComServer.Register(target, comServer, machineWide, handler)); if (machineWide || WindowsUtils.IsWindows8) { dispatcher.Add((AppRegistration appRegistration) => Windows.AppRegistration.Register(target, appRegistration, capabilities.OfType <VerbCapability>(), machineWide, handler)); } if (machineWide) { dispatcher.Add((Store.Model.Capabilities.DefaultProgram defaultProgram) => Windows.DefaultProgram.Register(target, defaultProgram, handler)); } } else if (UnixUtils.IsUnix) { dispatcher.Add((Store.Model.Capabilities.FileType fileType) => Unix.FileType.Register(target, fileType, machineWide, handler)); dispatcher.Add((Store.Model.Capabilities.UrlProtocol urlProtocol) => Unix.UrlProtocol.Register(target, urlProtocol, machineWide, handler)); dispatcher.Add((Store.Model.Capabilities.DefaultProgram defaultProgram) => Unix.DefaultProgram.Register(target, defaultProgram, machineWide, handler)); } dispatcher.Dispatch(capabilities); }
/// <summary> /// Reads the <see cref="DefaultCapability"/>s from <see cref="Store.Model.Feed.CapabilityLists"/> and creates a coressponding model for turning <see cref="AccessPoints.DefaultAccessPoint"/> on and off. /// </summary> private void LoadDefaultAccessPoints() { var dispatcher = new PerTypeDispatcher <Capability>(ignoreMissing: true) { (FileType fileType) => { var model = new FileTypeModel(fileType, IsCapabillityUsed <AccessPoints.FileType>(fileType)); FileTypes.Add(model); _capabilityModels.Add(model); }, (UrlProtocol urlProtocol) => { var model = new UrlProtocolModel(urlProtocol, IsCapabillityUsed <AccessPoints.UrlProtocol>(urlProtocol)); UrlProtocols.Add(model); _capabilityModels.Add(model); }, (AutoPlay autoPlay) => { var model = new AutoPlayModel(autoPlay, IsCapabillityUsed <AccessPoints.AutoPlay>(autoPlay)); AutoPlay.Add(model); _capabilityModels.Add(model); }, (ContextMenu contextMenu) => { var model = new ContextMenuModel(contextMenu, IsCapabillityUsed <AccessPoints.ContextMenu>(contextMenu)); ContextMenu.Add(model); _capabilityModels.Add(model); } }; if (_integrationManager.MachineWide) { dispatcher.Add((DefaultProgram defaultProgram) => { var model = new DefaultProgramModel(defaultProgram, IsCapabillityUsed <AccessPoints.DefaultProgram>(defaultProgram)); DefaultProgram.Add(model); _capabilityModels.Add(model); }); } dispatcher.Dispatch(AppEntry.CapabilityLists.CompatibleCapabilities()); }