Providing a common set of methods for interacting with files across storage providers
FileParty uses Microsoft.Extensions.DependencyInjection to register itself. Dependency Injection is not explicitly
required to use FileParty.
Register File Party by calling this.AddFileParty() either on an existing IServiceCollection or any object. If this
is not an IServiceCollection
a new Service Collection will be made and returned as a result of the method call; When not using Dependency Injection,
make sure to assign this to a variable.
Register each desired module calling a configuration action x => x.AddModule<ModuleName>(defaultConfigObject)
where defaultConfigObject is a StorageProviderConfiguration<TModule>
This command which will register a given module and its storage providers with the Service Collection. Any quantity of modules may be added this way.
If desired, a default module may be specified, when provided this module will be the default storage provider type
provided when either
FilePartyFactory or AsyncFilePartyFactory returns a storage provider. When not provided, the default module shall be
the last module loaded using the
AddModule<TModule>(config) command.
this.AddFileParty(config =>
config.AddModule<FileSystemModule>(new FileSystemConfiguration("C:\FilePartyBaseDirectory"))
.SetDefaultModule<FilePartyModule>()
)When you need access to an IAsyncStorageProvider or IStorageProvider there are a few options:
- Use Dependency Injection for either an
IAsyncStorageProviderorIStorageProviderand the appropriate factory will return a instance from the default module, or - Use Dependency Injection for either an
IAsyncFilePartyFactoryorIFilePartyFactoryand call one of the following methods:GetAsyncStorageProvider()orGetStorageProvider()to get a storage provider from the default module with the default configuration for that module, orGetAsyncStorageProvider<TModule>()orGetStorageProvider<TModule>()to get a storage provider from a specified module with the default configuration for that module, orGetAsyncStorageProvider<TModule>(StorageProviderConfiguration<TModule>)orGetStorageProvider<TModule>(StorageProviderConfiguration<TModule>)to get a storage provider from a specified module with a specified configuration.
The following methods are also available in the factory to return a more limited action set from the storage provider
- Storage Readers, which include methods to check to see if a file exists, to read a file stream, and get information
about a file
GetAsyncStorageReader()orGetStorageReader()GetAsyncStorageReader<TModule>()orGetStorageReader<TModule>()GetAsyncStorageReader<TModule>(StorageProviderConfiguration<TModule>)orGetStorageReader<TModule>(StorageProviderConfiguration<TModule>)
- Storage Writers, which include methods to Write and Delete a file stream
GetAsyncStorageWriter()orGetStorageWriter()GetAsyncStorageWriter<TModule>()orGetStorageWriter<TModule>()GetAsyncStorageWriter<TModule>(StorageProviderConfiguration<TModule>)orGetStorageWriter<TModule>(StorageProviderConfiguration<TModule>)
Use Dependency Injection to get an IWriteProgressSubscriptionManager. Use a delegate to subscribe to all or some write
progress events. Each module should have write progress updates implemented. When creating a FilePartyWriteRequest use
this Id to subscribe to write progress updates for a specific file stream.
Use Dependency Injection to get an IFilePartyFactoryModifier and use the sole method to set a new default module and
configuration. This will change which Storage Providers are returned by the default factory methods.
Create a project that implements:
- BaseAsyncStorageProvider
- BaseStorageProvider
- BaseFilePartyModule
Please be mindful to include updates for write progress.
Additional services may be registered in the module's independent service collection.
Just make an issue on the Repo.
- Contributions are welcome.
- Please make PRs into develop and remember to increment the version number for each project.
- Please name branches in the following formats
- /bugfix/issue-fixed
- /feature/feature-added
- Release PRs will go into main
- Please write unit tests
- If adding a new storage provider
- please make a new repository
- use the following namespace format, marking External as it is not maintained by Jankware:
FileParty.Providers.External.YourProvider
- let us know about it, we're very interested
- we may ask to make this part of the core code in the future