Gorgon
Show / Hide Table of Contents

Class ContentImportPlugIn

A plug in type that performs a custom import for content.

Inheritance
object
GorgonPlugIn
EditorPlugIn
ContentImportPlugIn
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 ContentImportPlugIn : EditorPlugIn, IGorgonNamedObject
Remarks

The content importer plug in allows an application to import external content and convert it to a type that the associated ContentPlugIn can handle. Content importers should be associated with the content produced by a ContentPlugIn in some way, but is not mandatory.

Content plug ins are automatically run whenever content is imported into the host application.

The content importer plug in provides an importer object that the host application calls to perform the import operation on file data. This content importer must implement the IEditorContentImporter. The host application will pass along the required objects to manipulate the file system, access the graphics interface, and other sets of functionality.

One use case for this would be to import content generated by an external application and convert it to your own custom content type. Another would be to handle versioning between content types where a newer format for the content supercedes a previous format. The importer would read the old version, and then upgrade to the later version.

Constructors

| Edit this page View Source

ContentImportPlugIn(string)

Initializes a new instance of the ContentImportPlugIn class.

Declaration
protected ContentImportPlugIn(string description)
Parameters
Type Name Description
string description

Optional description of the plugin.

See Also
ContentPlugIn

Fields

| Edit this page View Source

ImportOriginalFileNameAttr

An attribute name for the file metadata to indicate that this item was imported.

Declaration
public const string ImportOriginalFileNameAttr = "ImportOriginalName"
Field Value
Type Description
string
Remarks

Use this value to provide the original filename (and optionally, full path) for the original content being imported. This is stored in the ProjectItemMetadata for informational purposes and should not be used by the plug in.

See Also
ContentPlugIn

Properties

| Edit this page View Source

HostContentServices

Property to return the services from the host application.

Declaration
protected IHostContentServices HostContentServices { get; }
Property Value
Type Description
IHostContentServices
Remarks

Plug in developers that implement a common plug in type based on this base type, should assign this value to allow access to the common content services supplied by the host application.

This will be assigned during the initialization of the plug in.

See Also
IHostServices
| Edit this page View Source

PlugInType

Property to return the type of this plug in.

Declaration
public override sealed PlugInType PlugInType { get; }
Property Value
Type Description
PlugInType
Overrides
EditorPlugIn.PlugInType
Remarks

The PlugInType returned for this property indicates the general plug in functionality.

See Also
PlugInType
| Edit this page View Source

ProjectFileSystem

Property to return the file system used by the project.

Declaration
protected IGorgonFileSystem ProjectFileSystem { get; }
Property Value
Type Description
IGorgonFileSystem
Remarks

Importer plug ins can use this to read in dependencies and other content files from the project.

See Also
ContentPlugIn
| Edit this page View Source

TemporaryFileSystem

Property to return the file system used to hold temporary file data.

Declaration
protected IGorgonFileSystemWriter<Stream> TemporaryFileSystem { get; }
Property Value
Type Description
IGorgonFileSystemWriter<Stream>
Remarks

Importer plug ins can use this to write temporary working data, which is deleted after the project unloads, for use during the import process.

See Also
ContentPlugIn

Methods

| Edit this page View Source

CanOpenContent(string)

Function to determine if the content plugin can open the specified file.

Declaration
public bool CanOpenContent(string filePath)
Parameters
Type Name Description
string filePath

The file to evaluate.

Returns
Type Description
bool

true if the plugin can open the file, or false if not.

Remarks

This method is used to determine if the file specified by the filePath passed to the method can be opened by this plug in. If the method returns true, then the host application will convert the file using the importer produced by this plug in. Otherwise, if the method returns false, then the file is skipped.

The filePath is a path to the file on the project virtual file system. Passing a physical file system path to this method will not work.

This method calls the OnCanOpenContent(string) method to perform the file validation.

Exceptions
Type Condition
ArgumentNullException

Thrown when the filePath parameter is null.

ArgumentEmptyException

Thrown when the filePath parameter is empty.

See Also
OnCanOpenContent(string)
| Edit this page View Source

GetImporter()

Function to retrieve a content import

Declaration
public IEditorContentImporter GetImporter()
Returns
Type Description
IEditorContentImporter

A new IEditorContent object.

Remarks

This method creates a new instance, or retrieves an existing instance of the IEditorContentImporter used to perform the file import.

This method calls the OnCreateImporter() method to perform the creation of the importer object.

Exceptions
Type Condition
GorgonException

Thrown if the OnCreateImporter() method returns null.

See Also
OnCreateImporter()
| Edit this page View Source

Initialize(IHostContentServices)

Function to perform any required initialization for the plugin.

Declaration
public void Initialize(IHostContentServices hostServices)
Parameters
Type Name Description
IHostContentServices hostServices

The services passed from the host application to the plug in.

Remarks

This method provides the means to initialize the content importer plug in and passes functionality from the host application to the plug in.

Content plug ins inheriting from this base type can provide custom initialization by implementing the OnInitialize() method.

This method will only be called once when the plug in is loaded. It cannot and should not be called after it has been called during load.

important

This method is for external use, and is only used by the host application. Do not call this method.

Exceptions
Type Condition
ArgumentNullException

Thrown when the hostServices parameter is null.

See Also
ContentPlugIn
| Edit this page View Source

OnCanOpenContent(string)

Function to determine if the content plugin can open the specified file.

Declaration
protected abstract bool OnCanOpenContent(string filePath)
Parameters
Type Name Description
string filePath

The path to the file to evaluate.

Returns
Type Description
bool

true if the plugin can open the file, or false if not.

Remarks

This method is used to determine if the file specified by the filePath passed to the method can be opened by this plug in. If the method returns true, then the host application will convert the file using the importer produced by this plug in. Otherwise, if the method returns false, then the file is skipped.

The filePath is a path to the file on the project virtual file system.

Implementors may use whatever method they desire to determine if the file can be opened (e.g. checking file extensions, examining file headers, etc...).

See Also
ContentPlugIn
| Edit this page View Source

OnCreateImporter()

Function to open a content object from this plugin.

Declaration
protected abstract IEditorContentImporter OnCreateImporter()
Returns
Type Description
IEditorContentImporter

A new IEditorContentImporter object.

Remarks

This method creates an instance of the custom content importer. The application will use the object returned to perform the actual import process.

See Also
ContentPlugIn
| Edit this page View Source

OnInitialize()

Function to provide custom initialization for the plugin.

Declaration
protected virtual void OnInitialize()
Remarks

This method provides the means to perform custom initialization for an implementing content plug in type. Plug in developers can override this method to perform their own one-time setup for a custom plug in.

This method will only be called once when the plug in is loaded. It cannot be called after it has been called during load.

See Also
ContentPlugIn
| Edit this page View Source

OnProjectClosed()

Function to allow custom plug ins to implement custom actions when a project is closed.

Declaration
protected virtual void OnProjectClosed()
See Also
ContentPlugIn
| Edit this page View Source

OnProjectOpened()

Function to allow custom plug ins to implement custom actions when a project is created/opened.

Declaration
protected virtual void OnProjectOpened()
See Also
ContentPlugIn
| Edit this page View Source

OnShutdown()

Function to provide clean up for the plugin.

Declaration
protected virtual void OnShutdown()
Remarks

This method provides the means to perform custom cleanup for an implementing content plug in type. Plug in developers can override this method to perform their own one-time cleanup for a custom plug in.

This method will only be called once when the plug in is unloaded. It cannot be called after it has been called during unload.

See Also
ContentPlugIn
| Edit this page View Source

ProjectClosed()

Function called when a project is unloaded.

Declaration
public void ProjectClosed()
See Also
ContentPlugIn
| Edit this page View Source

ProjectOpened(IGorgonFileSystem, IGorgonFileSystemWriter<Stream>)

Function called when a project is loaded/created.

Declaration
public void ProjectOpened(IGorgonFileSystem projectFileSystem, IGorgonFileSystemWriter<Stream> tempFileSystem)
Parameters
Type Name Description
IGorgonFileSystem projectFileSystem

The file system used by the project.

IGorgonFileSystemWriter<Stream> tempFileSystem

The file system used to hold temporary working data.

See Also
ContentPlugIn
| Edit this page View Source

Shutdown()

Function to perform any required clean up for the plugin.

Declaration
public void Shutdown()
Remarks

This method provides the means to perform clean up of internal resources for the plug in.

Content plug ins inheriting from this base type can provide custom initialization by implementing the OnShutdown() method.

This method will only be called during unloading of the plug in (typically when the host application shuts down).

important

This method is for external use, and is only used by the host application. Do not call this method.

See Also
ContentPlugIn

Implements

IGorgonNamedObject

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)

See Also

ContentPlugIn
  • 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