Class ContentImportPlugIn
A plug in type that performs a custom import for content.
Implements
Inherited Members
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 SourceContentImportPlugIn(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
Fields
| Edit this page View SourceImportOriginalFileNameAttr
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
Properties
| Edit this page View SourceHostContentServices
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
| Edit this page View SourcePlugInType
Property to return the type of this plug in.
Declaration
public override sealed PlugInType PlugInType { get; }
Property Value
Type | Description |
---|---|
PlugInType |
Overrides
Remarks
The PlugInType returned for this property indicates the general plug in functionality.
See Also
| Edit this page View SourceProjectFileSystem
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
| Edit this page View SourceTemporaryFileSystem
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
Methods
| Edit this page View SourceCanOpenContent(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 |
ArgumentEmptyException | Thrown when the |
See Also
| Edit this page View SourceGetImporter()
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
| Edit this page View SourceInitialize(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 |
See Also
| Edit this page View SourceOnCanOpenContent(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
| Edit this page View SourceOnCreateImporter()
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
| Edit this page View SourceOnInitialize()
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
| Edit this page View SourceOnProjectClosed()
Function to allow custom plug ins to implement custom actions when a project is closed.
Declaration
protected virtual void OnProjectClosed()
See Also
| Edit this page View SourceOnProjectOpened()
Function to allow custom plug ins to implement custom actions when a project is created/opened.
Declaration
protected virtual void OnProjectOpened()
See Also
| Edit this page View SourceOnShutdown()
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
| Edit this page View SourceProjectClosed()
Function called when a project is unloaded.
Declaration
public void ProjectClosed()
See Also
| Edit this page View SourceProjectOpened(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
| Edit this page View SourceShutdown()
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.