ZDK.ResourceManager.Abstractions 0.2.0-nightly.202506100108

This is a prerelease version of ZDK.ResourceManager.Abstractions.
dotnet add package ZDK.ResourceManager.Abstractions --version 0.2.0-nightly.202506100108
                    
NuGet\Install-Package ZDK.ResourceManager.Abstractions -Version 0.2.0-nightly.202506100108
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZDK.ResourceManager.Abstractions" Version="0.2.0-nightly.202506100108" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZDK.ResourceManager.Abstractions" Version="0.2.0-nightly.202506100108" />
                    
Directory.Packages.props
<PackageReference Include="ZDK.ResourceManager.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZDK.ResourceManager.Abstractions --version 0.2.0-nightly.202506100108
                    
#r "nuget: ZDK.ResourceManager.Abstractions, 0.2.0-nightly.202506100108"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ZDK.ResourceManager.Abstractions&version=0.2.0-nightly.202506100108&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=ZDK.ResourceManager.Abstractions&version=0.2.0-nightly.202506100108&prerelease
                    
Install as a Cake Tool

ZDK Resource Management

License: MIT Abstractions

A flexible and extensible set of .NET libraries for managing application resources. This project provides a core framework with abstractions and allows for different provider implementations (e.g., File System).

Overview

The ZDK Resource Management libraries are designed to provide a clean, configurable, and testable way to handle external resources in your .NET applications. "ZDK" is the prefix for our company's open-source projects, indicating that these libraries are developed and maintained by ZDK Network Key Features:

  • Abstraction-First Design: Core interfaces define the contracts, allowing for different underlying implementations.
  • Resource Management: Load and access various types of resource files (e.g., configuration, assets).
  • Provider Model: Easily extend the system with custom providers for different data sources (e.g., File System, FTP, AWS S3, Databases).
  • Optional File Watching: Built-in support for watching file system changes and automatically reloading resources (configurable).
  • Dependency Injection Friendly: Includes extension methods for easy integration with Microsoft.Extensions.DependencyInjection.
  • Configurable Behavior: Options for handling missing files, etc.

Packages

This solution is structured into several NuGet packages:

ZDK.ResourceManager.Abstractions

Provides the core interfaces and enums for the resource file management system. This package is essential for defining the contracts that other resource providers will implement.

ZDK.ResourceManager.FileSystem Provides implementations for loading resource files from the local file system and watching for changes. This package includes DI extension methods for easy integration into your application.

Resource Management

  • ZDK.ResourceManager.Abstractions: Contains the core interfaces and enums for the resource file management system (IZDKResourceFileManager, IZDKResourceFileProvider, IZDKResourceFileWatcher, IZDKResourceFile, IZDKResourceConfiguration, etc.).
  • ZDK.ResourceManager.FileSystem: Provides implementations for loading resource files from the local file system and watching for changes. Includes DI extension methods (AddZDKFileSystemResourceManager).

Getting Started

Prerequisites

  • .NET 9 SDK

Installation

This project is currently in early development. Nightly builds are published as NuGet packages and are available for early testing. Please be aware that these versions are not stable and may introduce breaking changes.

To install a nightly build, you'll need to configure your NuGet sources to include the nightly feed (details will be provided when the feed is established). Once configured, you can install the packages using the .NET CLI:

  dotnet add package ZDK.ResourceManager.Abstractions --version <nightly-version>
  dotnet add package ZDK.ResourceManager.FileSystem --version <nightly-version>

Replace <nightly-version> with the specific version number of the nightly build you wish to use. Stable releases will be made available on NuGet.org once the project reaches a mature state.

Basic Usage (File System Resource Management)

  1. Place your resource files in a directory.

  2. Configure services in your Program.cs:

    using Microsoft.Extensions.DependencyInjection;
    using ZDK.ResourceManager.Abstractions;
    using ZDK.ResourceManager.FileSystem; // For extension methods and concrete config
    
    var builder = WebApplication.CreateBuilder(args); // Or Host.CreateDefaultBuilder()
    
    // Add ZDK File System Resource Manager
    builder.Services.AddZDKFileSystemResourceManager(config =>
    {
        config.ResourceDirectoryPath = "path/to/your/resources";
        config.MissingResourceFileHandleMethod = ZDKMissingResourceFileHandleMethod.ThrowException;
        config.ReloadOnFileChange = true; // Enable file watching
    });
    
    // ... other service registrations
    
    var app = builder.Build();
    
    // ... app configuration
    app.Run();
    
  3. Inject and use IZDKResourceFileManager:

    using ZDK.ResourceManager.Abstractions;
    using System.IO;
    
    public class MyFileService
    {
        private readonly IZDKResourceFileManager _resourceManager;
    
        public MyFileService(IZDKResourceFileManager resourceManager)
        {
            _resourceManager = resourceManager;
        }
    
        public string? ReadConfigFile()
        {
            IZDKResourceFile? configFile = _resourceManager.GetFile("config.json");
            if (configFile != null)
            {
                using (var stream = configFile.GetStream())
                using (var reader = new StreamReader(stream))
                {
                    return reader.ReadToEnd();
                }
            }
            return null;
        }
    }
    

Configuration Options

Detailed configuration options are available for each provider. Please refer to the specific configuration classes:

  • ZDKFileSystemResourceConfiguration

Extending the System

Creating Custom Providers

To support other data sources (e.g., databases, cloud storage):

  1. Implement the relevant interfaces from ZDK.ResourceManager.Abstractions (e.g., IZDKResourceFileProvider).
  2. Create a corresponding configuration class if specific settings are needed.
  3. Create DI extension methods for easy registration of your custom provider.

Contributing

Contributions are welcome! If you'd like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature-name).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add some feature').
  5. Push to the branch (git push origin feature/your-feature-name).
  6. Open a pull request.

Please make sure to update tests as appropriate.

Building the Project

This project targets .NET 9. To build the solution, ensure you have the .NET 9 SDK installed on your machine.

  1. Clone the repository:
    git clone https://github.com/bberka/ZDK.ResourceManager
    cd ZDK.ResourceManager
  1. Restore dependencies:
    dotnet restore

3Build the solution:

    dotnet build

You can also open the .sln file in Visual Studio 2022 (with .NET 9 SDK installed) and build from there.

Running Tests

Due to early development, tests are not yet implemented. Once the project stabilizes, unit tests will be added to ensure reliability and correctness.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About ZDK.Localization package

ZDK.Localization project is removed from this repository. It is mosty likely won't be reintroduced in the future.

You either have to write your own localization provider or use existing ones like Microsoft.Extensions.Localization or Localization.AspNetCore packages and import files from this project as needed.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ZDK.ResourceManager.Abstractions:

Package Downloads
ZDK.ResourceManager.FileSystem

Provides a FileSystem-based resource manager for ZDK.ResourceManager.

GitHub repositories

This package is not used by any popular GitHub repositories.