コード例 #1
0
        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;
            }
        }
コード例 #2
0
        public ImageSource GetIconSource(string extensionName)
        {
            extensionName = FileDocumentService.NormalizeExtensionName(extensionName);
            FileTypeInfo fileTypeInfo;

            if (_fileTypes.TryGetValue(extensionName, out fileTypeInfo))
            {
                return(fileTypeInfo.IconSource);
            }

            return(null);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 static FileDocumentService()
 {
     FileDocumentService.Instance = new FileDocumentService();
     DocumentServiceManager.Instance.Register(FileDocumentService.Instance);
 }
コード例 #5
0
 public bool HasFileViewerService(string extensionName)
 {
     return(_services.ContainsKey(FileDocumentService.NormalizeExtensionName(extensionName)));
 }