Class FileWriterPlugIn
An interface for file output plug ins.
Implements
Inherited Members
Namespace: Gorgon.Editor.PlugIns
Assembly: Gorgon.Editor.API.dll
Syntax
public abstract class FileWriterPlugIn : EditorPlugIn, IGorgonNamedObject
Constructors
| Edit this page View SourceFileWriterPlugIn(string, IEnumerable<GorgonFileExtension>)
Initializes a new instance of the FileWriterPlugIn class.
Declaration
protected FileWriterPlugIn(string description, IEnumerable<GorgonFileExtension> fileExtensions)
Parameters
Type | Name | Description |
---|---|---|
string | description | Friendly description of the plug in. |
IEnumerable<GorgonFileExtension> | fileExtensions | The file of common file name extensions supported by this writer. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
Properties
| Edit this page View SourceCapabilities
Property to return the capabilities of the writer.
Declaration
public abstract WriterCapabilities Capabilities { get; }
Property Value
Type | Description |
---|---|
WriterCapabilities |
Compression
Property to set or return the percentage for compression (if supported).
Declaration
public virtual float Compression { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
This value is within a range of 0..1 where 0 means no compression, and 1 means use the maximum compression available by the compression provider.
Higher compression values will mean that it takes longer to write the file.
The default value is 0.5f.
FileExtensions
Property to return the file extensions (and descriptions) for this content type.
Declaration
public IGorgonNamedObjectReadOnlyDictionary<GorgonFileExtension> FileExtensions { get; }
Property Value
Type | Description |
---|---|
IGorgonNamedObjectReadOnlyDictionary<GorgonFileExtension> |
Remarks
Plug in developers must provide common file extensions supported by the plug in type, or else this plug in cannot be used.
PlugInType
Property to return the type of plug in.
Declaration
public override sealed PlugInType PlugInType { get; }
Property Value
Type | Description |
---|---|
PlugInType |
Overrides
| Edit this page View SourceV2PlugInName
Property to return the equivalent type name for v2 of the Gorgon file writer plugin.
Declaration
public virtual string V2PlugInName { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
This is here to facilitate importing of file metadata from v2 of the gorgon editor files. Only specify a compatible type here, otherwise things will go wrong.
Methods
| Edit this page View SourceCanWriteFile(string)
Function to determine if this writer can write the type of file specified in the path.
Declaration
public bool CanWriteFile(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The path to the file. |
Returns
Type | Description |
---|---|
bool | true if the writer can write the type of file, or false if it cannot. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
Initialize(IHostServices)
Function to initialize the plug in.
Declaration
public void Initialize(IHostServices hostServices)
Parameters
Type | Name | Description |
---|---|---|
IHostServices | hostServices | The services to pass from the host application to the plug in. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
OnEvaluateCanWriteFile(string)
Function to determine if the type of file specified can be written by this plug in.
Declaration
protected abstract bool OnEvaluateCanWriteFile(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | The path to the file to evaluate. |
Returns
Type | Description |
---|---|
bool | true if the writer can write the type of file, or false if it cannot. |
Remarks
The filePath
parameter is never null, and is guaranteed to exist when this method is called. If neither of these are true, then this method is not called.
OnWriteAsync(string, DirectoryInfo, Action<int, int, bool>, CancellationToken)
Function to write the file to the specified path.
Declaration
protected abstract Task OnWriteAsync(string filePath, DirectoryInfo workspace, Action<int, int, bool> progressCallback, CancellationToken cancelToken)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | The path to the file to save the data into. |
DirectoryInfo | workspace | The directory that represents the workspace for our file system data. |
Action<int, int, bool> | progressCallback | The method used to report progress back to the application. |
CancellationToken | cancelToken | The token used for cancelling the operation. |
Returns
Type | Description |
---|---|
Task | A task for asynchronous operation. |
Remarks
The progressCallback
is a method that takes 3 parameters:
- The current item number being written.
- The total number of items to write.
- true if the operation can be cancelled, or false if not.
WriteAsync(string, DirectoryInfo, Action<int, int, bool>, CancellationToken)
Function to write the application data into a stream.
Declaration
public Task WriteAsync(string filePath, DirectoryInfo workspace, Action<int, int, bool> progressCallback, CancellationToken cancelToken)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | The path to the file to save the data into. |
DirectoryInfo | workspace | The directory that represents the workspace for our file system data. |
Action<int, int, bool> | progressCallback | The method used to report progress back to the application. |
CancellationToken | cancelToken | The token used for cancelling the operation. |
Returns
Type | Description |
---|---|
Task | A task for asynchronous operation. |
Remarks
The progressCallback
is a method that takes 3 parameters:
- The current item number being written.
- The total number of items to write.
- true if the operation can be cancelled, or false if not.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
DirectoryNotFoundException | Thrown if the |
IOException | Thrown if the stream is read only. |