TheFusionWorks.ResourceManager
1.0.1
dotnet add package TheFusionWorks.ResourceManager --version 1.0.1
NuGet\Install-Package TheFusionWorks.ResourceManager -Version 1.0.1
<PackageReference Include="TheFusionWorks.ResourceManager" Version="1.0.1" />
paket add TheFusionWorks.ResourceManager --version 1.0.1
#r "nuget: TheFusionWorks.ResourceManager, 1.0.1"
// Install TheFusionWorks.ResourceManager as a Cake Addin #addin nuget:?package=TheFusionWorks.ResourceManager&version=1.0.1 // Install TheFusionWorks.ResourceManager as a Cake Tool #tool nuget:?package=TheFusionWorks.ResourceManager&version=1.0.1
TheFusionWorks.ResourceManager
TheFusionWorks.ResourceManager
is a versatile and extensible NuGet package for managing various types of resources, providing a unified interface for resource CRUD (Create, Read, Update, Delete) operations. It currently supports local file systems and Azure Blob Storage as interchangeable resource managers.
Features
- Unified Interface: Provides a consistent interface for interacting with different types of resource managers.
- Extensible: Easily add support for more types of storage by implementing the
IResourceManager
andIResource
interfaces. - Seamless Switching: Switching between resource types is as simple as changing the injected dependency, making it easy to switch between different storage backends (e.g., from a local file system to Azure Blob Storage).
- Dependency Injection Friendly: Designed with dependency injection in mind, promoting flexible and modular software architectures.
Installation
To install the package, use the following command in the NuGet Package Manager Console:
Install-Package TheFusionWorks.ResourceManager
Or, use the .NET CLI:
dotnet add package TheFusionWorks.ResourceManager
Quick Start Guide
Interfaces
The package revolves around two main interfaces:
IResourceManager
: Defines the operations for managing resources.IResource
: Represents a resource that can be managed.
These interfaces abstract the complexity of different storage backends, allowing developers to write code that works with any implemented resource type.
Example Usage
1. Setup Dependency Injection
To get started, simply inject the desired IResourceManager
implementation into your service or application.
For example, using Microsoft.Extensions.DependencyInjection
:
using Microsoft.Extensions.DependencyInjection;
using TheFusionWorks.ResourceManager;
using TheFusionWorks.ResourceManager.FileSystem;
using TheFusionWorks.ResourceManager.AzureBlobStorage;
var services = new ServiceCollection();
// For local file system management
services.AddScoped<IResourceManager, FileManager>();
// Or, for Azure Blob Storage management
// services.AddScoped<IResourceManager, BlobStorageManager>();
var serviceProvider = services.BuildServiceProvider();
2. Switching Resource Types
Switching from managing resources on a local file system to Azure Blob Storage is as simple as changing the injected implementation:
// Change from FileManager to BlobStorageManager
services.AddScoped<IResourceManager, BlobStorageManager>();
Your application code does not need to change, making it incredibly flexible for different environments and storage backends.
Implementations
FileManager
FileManager
is used for managing resources on a local file system. It implements IResourceManager
to provide CRUD operations for files, including creating, reading, updating, and deleting.
BlobStorageManager
BlobStorageManager
is used for managing resources in Azure Blob Storage. It also implements IResourceManager
, enabling the same CRUD operations but for blobs in Azure.
Extending The Package
To extend TheFusionWorks.ResourceManager for additional types of resources, simply create a new class that implements IResourceManager
and IResource
interfaces. This way, the package can be extended to support new storage backends like Amazon S3, Google Cloud Storage, or even databases.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Azure.Storage.Blobs (>= 12.23.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.