/// <summary> /// Reads the <see cref="DefaultCapability"/>s from <see cref="Model.Feed.CapabilityLists"/> and creates a corresponding model for turning <see cref="AccessPoints.DefaultAccessPoint"/> on and off. /// </summary> private void LoadDefaultAccessPoints() { foreach (var capability in AppEntry.CapabilityLists.CompatibleCapabilities()) { switch (capability) { case FileType fileType: { var model = new FileTypeModel(fileType, IsCapabillityUsed <AccessPoints.FileType>(fileType)); FileTypes.Add(model); _capabilityModels.Add(model); break; } case UrlProtocol urlProtocol: { var model = new UrlProtocolModel(urlProtocol, IsCapabillityUsed <AccessPoints.UrlProtocol>(urlProtocol)); UrlProtocols.Add(model); _capabilityModels.Add(model); break; } case AutoPlay autoPlay: { var model = new AutoPlayModel(autoPlay, IsCapabillityUsed <AccessPoints.AutoPlay>(autoPlay)); AutoPlay.Add(model); _capabilityModels.Add(model); break; } case ContextMenu contextMenu: { var model = new ContextMenuModel(contextMenu, IsCapabillityUsed <AccessPoints.ContextMenu>(contextMenu)); ContextMenu.Add(model); _capabilityModels.Add(model); break; } case DefaultProgram defaultProgram: { if (!_integrationManager.MachineWide) { break; } var model = new DefaultProgramModel(defaultProgram, IsCapabillityUsed <AccessPoints.DefaultProgram>(defaultProgram)); DefaultProgram.Add(model); _capabilityModels.Add(model); break; } } } bool IsCapabillityUsed <T>(Capability toCheck) where T : AccessPoints.DefaultAccessPoint => AppEntry.AccessPoints != null && AppEntry.AccessPoints.Entries.OfType <T>().Any(accessPoint => accessPoint.Capability == toCheck.ID); }
/// <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()); }