Class FileViewerBase
- Namespace
- Acuit.Pinpoint.Workstation.ReferenceContent
- Assembly
- Acuit.Pinpoint.Workstation.Interfaces.dll
A base class to make creating file viewers more convenient.
public abstract class FileViewerBase : IFileViewer
- Inheritance
-
FileViewerBase
- Implements
- Inherited Members
Constructors
FileViewerBase(params string[])
Initializes a new instance of the FileViewerBase class.
protected FileViewerBase(params string[] supportedExtensions)
Parameters
supportedExtensionsstring[]The file extensions that this viewer can handle, including periods (e.g., ".htm", ".html")
Exceptions
- ArgumentNullException
supportedExtensionsis null.
Properties
SupportedFileExtensions
Gets the collection of file extensions (including the period) that this viewer can handle (e.g., ".htm", ".html").
public IEnumerable<string> SupportedFileExtensions { get; }
Property Value
Methods
CreateViewerAsync(string, IEnumerable<KeyValuePair<string, string>>)
Creates a viewer for a file.
public abstract Task<object> CreateViewerAsync(string fileName, IEnumerable<KeyValuePair<string, string>> parameters)
Parameters
fileNamestringThe file name.
parametersIEnumerable<KeyValuePair<string, string>>Viewer-specific parameters.
Returns
- Task<object>
A task that represents the asynchronous operation. The value of its Result property contains the file viewer content, which will be displayed via a ContentControl (i.e., its Content property will be set to this value).
Remarks
This will be called from the UI thread. Any WPF elements that are created for the viewer must be created from the UI thread.
If this throws an exception (either synchronously or asynchronously), the exception message will be shown as an error message where the content would be displayed.
Exceptions
- Exception
The viewer could not be created due to any error, such as a corrupt file.
TryGetParameter(IEnumerable<KeyValuePair<string, string>>, string, out bool)
Tries to get a bool parameter value.
protected static bool TryGetParameter(IEnumerable<KeyValuePair<string, string>> parameters, string name, out bool value)
Parameters
parametersIEnumerable<KeyValuePair<string, string>>The parameters (i.e., which were passed to CreateViewerAsync(string, IEnumerable<KeyValuePair<string, string>>)).
namestringThe name of the parameter to retrieve, case-insensitive.
valueboolThe resulting value.
Returns
Remarks
The parameters are enumerated until the first one matching name (case-insensitive) is found.
The value is then attempted to be parsed as a bool, ignoring leading and trailing space.
True, Yes, 1 (case-insensitive) are parsed as true.
False, No, 0 (case-insensitive) are parsed as false.
Any other value will fail to be parsed as a bool.
TryGetParameter(IEnumerable<KeyValuePair<string, string>>, string, out double)
Tries to get a double parameter value.
protected static bool TryGetParameter(IEnumerable<KeyValuePair<string, string>> parameters, string name, out double value)
Parameters
parametersIEnumerable<KeyValuePair<string, string>>The parameters (i.e., which were passed to CreateViewerAsync(string, IEnumerable<KeyValuePair<string, string>>)).
namestringThe name of the parameter to retrieve, case-insensitive.
valuedoubleThe resulting value.
Returns
Remarks
The parameters are enumerated until the first one matching name (case-insensitive) is found.
The value is then attempted to be parsed as a double, ignoring leading and trailing space.
TryGetParameter(IEnumerable<KeyValuePair<string, string>>, string, out int)
Tries to get an int parameter value.
protected static bool TryGetParameter(IEnumerable<KeyValuePair<string, string>> parameters, string name, out int value)
Parameters
parametersIEnumerable<KeyValuePair<string, string>>The parameters (i.e., which were passed to CreateViewerAsync(string, IEnumerable<KeyValuePair<string, string>>)).
namestringThe name of the parameter to retrieve, case-insensitive.
valueintThe resulting value.
Returns
Remarks
The parameters are enumerated until the first one matching name (case-insensitive) is found.
The value is then attempted to be parsed as an int, ignoring leading and trailing space.
TryGetParameter(IEnumerable<KeyValuePair<string, string>>, string, out string)
Tries to get a string parameter value.
protected static bool TryGetParameter(IEnumerable<KeyValuePair<string, string>> parameters, string name, out string value)
Parameters
parametersIEnumerable<KeyValuePair<string, string>>The parameters (i.e., which were passed to CreateViewerAsync(string, IEnumerable<KeyValuePair<string, string>>)).
namestringThe name of the parameter to retrieve, case-insensitive.
valuestringThe resulting value.
Returns
Remarks
The parameters are enumerated until the first one matching name (case-insensitive) is found.