Gorgon
Show / Hide Table of Contents

Class FileWriterPlugIn

An interface for file output plug ins.

Inheritance
object
GorgonPlugIn
EditorPlugIn
FileWriterPlugIn
Implements
IGorgonNamedObject
Inherited Members
EditorPlugIn.HostServices
EditorPlugIn.OnGetSettings()
EditorPlugIn.OnGetPlugInAvailability()
EditorPlugIn.GetPlugInSettings()
EditorPlugIn.IsPlugInAvailable()
GorgonPlugIn.Name
GorgonPlugIn.Assembly
GorgonPlugIn.PlugInPath
GorgonPlugIn.Description
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.Editor.PlugIns
Assembly: Gorgon.Editor.API.dll
Syntax
public abstract class FileWriterPlugIn : EditorPlugIn, IGorgonNamedObject

Constructors

| Edit this page View Source

FileWriterPlugIn(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 fileExtensions parameter is null.

Properties

| Edit this page View Source

Capabilities

Property to return the capabilities of the writer.

Declaration
public abstract WriterCapabilities Capabilities { get; }
Property Value
Type Description
WriterCapabilities
| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

PlugInType

Property to return the type of plug in.

Declaration
public override sealed PlugInType PlugInType { get; }
Property Value
Type Description
PlugInType
Overrides
EditorPlugIn.PlugInType
| Edit this page View Source

V2PlugInName

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 Source

CanWriteFile(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 path parameter is null.

ArgumentEmptyException

Thrown when the path parameter is empty.

| Edit this page View Source

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 hostServices parameter is null.

| Edit this page View Source

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.

| Edit this page View Source

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:

  1. The current item number being written.
  2. The total number of items to write.
  3. true if the operation can be cancelled, or false if not.
This progress method is optional, and if null is passed, then no progress is reported.
| Edit this page View Source

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:

  1. The current item number being written.
  2. The total number of items to write.
  3. true if the operation can be cancelled, or false if not.
This progress method is optional, and if null is passed, then no progress is reported.
Exceptions
Type Condition
ArgumentNullException

Thrown when the filePath, or the workspace parameter is empty.

DirectoryNotFoundException

Thrown if the workspace directory does not exist.

IOException

Thrown if the stream is read only.

Implements

IGorgonNamedObject

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author