AlirezaMahDev.Extensions.File.Abstractions 0.0.1-alpha7

This is a prerelease version of AlirezaMahDev.Extensions.File.Abstractions.
dotnet add package AlirezaMahDev.Extensions.File.Abstractions --version 0.0.1-alpha7
                    
NuGet\Install-Package AlirezaMahDev.Extensions.File.Abstractions -Version 0.0.1-alpha7
                    
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="AlirezaMahDev.Extensions.File.Abstractions" Version="0.0.1-alpha7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlirezaMahDev.Extensions.File.Abstractions" Version="0.0.1-alpha7" />
                    
Directory.Packages.props
<PackageReference Include="AlirezaMahDev.Extensions.File.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 AlirezaMahDev.Extensions.File.Abstractions --version 0.0.1-alpha7
                    
#r "nuget: AlirezaMahDev.Extensions.File.Abstractions, 0.0.1-alpha7"
                    
#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.
#:package AlirezaMahDev.Extensions.File.Abstractions@0.0.1-alpha7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AlirezaMahDev.Extensions.File.Abstractions&version=0.0.1-alpha7&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=AlirezaMahDev.Extensions.File.Abstractions&version=0.0.1-alpha7&prerelease
                    
Install as a Cake Tool

AlirezaMahDev.Extensions.File.Abstractions

Project Description

This project provides a set of abstractions for file-based operations in the AlirezaMahDev.Extensions ecosystem. It defines interfaces for file access, service management, and configuration, enabling consistent and type-safe file handling across applications.

Key Features

  • Unified File Access: Standardized interface for file operations
  • Thread-Safe Operations: Built-in support for concurrent access
  • Flexible Configuration: Extensible options for file handling
  • Asynchronous Support: Full async/await pattern support
  • Stream-Based Operations: Efficient handling of file streams
  • Dependency Injection: Seamless integration with .NET's DI container

Core Components

IFileService

Main service interface for accessing files:

  • Access(string name): Gets a file accessor for the specified file

IFileAccess

Provides thread-safe access to file operations:

  • Access(): Performs read operations on the file
  • Replace(): Replaces the entire file content
  • Change(): Modifies file content with a transformation
  • Async variants of all methods available

IFileBuilder

Fluent interface for configuring file services:

  • Extends IBuilderBase<FileOptions>
  • Used with dependency injection to configure file handling

FileOptions

Configuration options for file handling:

  • Path: Base directory for file operations (defaults to ./.data)

Usage Example

// Register file services
services.AddFile(builder =>
{
    builder.OptionsBuilder.Configure(options =>
    {
        options.Path = "./App_Data";
    });
});

// Resolve and use
var fileService = serviceProvider.GetRequiredService<IFileService>();

// Access a file
var fileAccess = fileService.Access("data.json");

// Read from file
var content = fileAccess.Access(stream => 
{
    using var reader = new StreamReader(stream);
    return reader.ReadToEnd();
});

// Write to file
fileAccess.Replace(stream => 
{
    using var writer = new StreamWriter(stream);
    writer.Write("New content");
});

Dependencies

Project Dependencies

  • AlirezaMahDev.Extensions.Abstractions: Core extension infrastructure

  • AlirezaMahDev.Extensions.Abstractions: Uses the base builder and options interfaces to maintain consistency with the broader framework

Why this dependency? The file abstractions follow the same builder and configuration patterns established by the core abstractions, ensuring a unified API experience.

Key Components

IFileService

Defines the interface for managing file access. Provides methods to obtain file access objects for specific files.

IFileAccess

Represents access to a specific file, providing methods to read, write, and manipulate file content.

IFileBuilder

Defines the builder pattern for configuring file services within the dependency injection container.

FileOptions

Configuration options for file services, implementing IOptionsBase to integrate with the configuration system.

These abstractions enable testable, mockable, and consistent file operations throughout the application.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 (3)

Showing the top 3 NuGet packages that depend on AlirezaMahDev.Extensions.File.Abstractions:

Package Downloads
AlirezaMahDev.Extensions.File

Package Description

AlirezaMahDev.Extensions.File.Data.Abstractions

Package Description

AlirezaMahDev.Extensions.File.Json.Abstractions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.1-alpha7 413 12/8/2025
0.0.1-alpha 275 12/7/2025