Class GorgonFileSystemProviderFactory
A factory object used to create file system provider plug ins.
Implements
Inherited Members
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 SourceGorgonFileSystemProviderFactory(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 |
Methods
| Edit this page View SourceCreateProvider(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 |
ArgumentEmptyException | Thrown when the |
ArgumentException | Thrown when the driver type name specified by -or- Thrown when the |
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 |
ArgumentEmptyException | Thrown when the |
ArgumentException | Thrown when the |