public void RegisterViewer(IFileViewerService service) { if (service == null) { throw new ArgumentNullException(nameof(service)); } if (service.SupportedFileTypes == null || service.SupportedFileTypes.Length == 0) { throw new ArgumentException("service", "one or more supported file types required"); } foreach (var fileType in service.SupportedFileTypes) { var normalizedExtensionName = FileDocumentService.NormalizeExtensionName(fileType.ExtensionName); this.LogInfo("registering FileViewerService '{0}' for file type '{1}'", service.Name, normalizedExtensionName); IFileViewerService existedService; if (_services.TryGetValue(normalizedExtensionName, out existedService)) { this.LogWarning("a FileViewerService '{0}' of file type '{1}' is already existed, it will be replaced", existedService.Name, normalizedExtensionName); } _services[normalizedExtensionName] = service; _fileTypes[normalizedExtensionName] = fileType; } }
public ImageSource GetIconSource(string extensionName) { extensionName = FileDocumentService.NormalizeExtensionName(extensionName); FileTypeInfo fileTypeInfo; if (_fileTypes.TryGetValue(extensionName, out fileTypeInfo)) { return(fileTypeInfo.IconSource); } return(null); }
public IFileViewerService GetFileViewerService(string extensionName) { extensionName = FileDocumentService.NormalizeExtensionName(extensionName); IFileViewerService service; if (_services.TryGetValue(extensionName, out service)) { return(service); } this.LogWarning("no FileViewerService for extension name '{0}' found", extensionName); return(null); }
public bool HasFileViewerService(string extensionName) { return(_services.ContainsKey(FileDocumentService.NormalizeExtensionName(extensionName))); }