Gorgon
Show / Hide Table of Contents

Class GorgonFileSystemProviderFactory

A factory object used to create file system provider plug ins.

Inheritance
object
GorgonFileSystemProviderFactory
Implements
IGorgonFileSystemProviderFactory
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: Gorgon.IO.Providers
Assembly: Gorgon.FileSystem.dll
Syntax
public sealed class GorgonFileSystemProviderFactory : IGorgonFileSystemProviderFactory
Remarks

This will generate providers that will allow access to different types of file systems. For example, a user may create a file system provider that will open 7-zip files, but the IGorgonFileSystem will not know how to read those files without the appropriate provider. This object would be used to load that 7-zip provider, and add it to the file system object so that it will know how to mount those file types.

File system providers are plug ins, and should have their assemblies loaded by the GorgonMefPlugInCache before using this method and a IGorgonPlugInService should be created in order to pass it to this factory.

Examples

The following example shows how to use the provider factory:

// In a real world application, you would keep your cache for as long as you need your plug ins.
// Premature disposal can cause errors.
using (GorgonMefPlugInCache cache = new GorgonMefPlugInCache())
{
	// Create the provider factory.
	IGorgonFileSystemProviderFactory factory = new GorgonFileSystemProviderFactory(cache);

	// Get our provider from the factory.
	IGorgonFileSystemProvider provider = CreateProvider(@"C:\FileSystemProviders\Gorgon.FileSystem.7zip.dll", "Gorgon.FileSystem.SevenZipProvider");

	// Mount the file system.
	IGorgonFileSystem fileSystem = new GorgonFileSystem(provider);

	fileSystem.Mount("c:\path\to\your\archive\file.7z");

	// Do stuff...
}

Constructors

| Edit this page View Source

GorgonFileSystemProviderFactory(GorgonMefPlugInCache, IGorgonLog)

Initializes a new instance of the GorgonFileSystemProviderFactory class.

Declaration
public GorgonFileSystemProviderFactory(GorgonMefPlugInCache plugInCache, IGorgonLog log = null)
Parameters
Type Name Description
GorgonMefPlugInCache plugInCache

The cache used to load and store plugin assemblies.

IGorgonLog log

[Optional] The application log file.

Exceptions
Type Condition
ArgumentNullException

Thrown when the plugInCache parameter is null.

Methods

| Edit this page View Source

CreateProvider(string, string)

Function to create a new file system provider.

Declaration
public GorgonFileSystemProvider CreateProvider(string path, string providerPlugInName)
Parameters
Type Name Description
string path

The path to the file system plug in assemblies.

string providerPlugInName

The fully qualified type name of the plugin that contains the file system provider.

Returns
Type Description
GorgonFileSystemProvider

The new file system provider object, or if it was previously created, the previously created instance.

Exceptions
Type Condition
ArgumentNullException

Thrown when the path, or the providerPlugInName is null

ArgumentEmptyException

Thrown when the path, or the providerPlugInName is empty.

ArgumentException

Thrown when the driver type name specified by providerPlugInName was not found in any of the loaded plug in assemblies.

-or-

Thrown when the path was invalid.

| Edit this page View Source

CreateProviders(string)

Function to retrieve all the file system providers from the available plugins in the plugin service.

Declaration
public IReadOnlyList<GorgonFileSystemProvider> CreateProviders(string path)
Parameters
Type Name Description
string path

The path to the file system plug in assemblies.

Returns
Type Description
IReadOnlyList<GorgonFileSystemProvider>

A list of file system providers

Exceptions
Type Condition
ArgumentNullException

Thrown when the path is null

ArgumentEmptyException

Thrown when the path is empty.

ArgumentException

Thrown when the path was invalid.

Implements

IGorgonFileSystemProviderFactory

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