SingularFrameworkCore.Repository.FileSystem.BinaryFile
0.1.0-alpha
See the version list below for details.
dotnet add package SingularFrameworkCore.Repository.FileSystem.BinaryFile --version 0.1.0-alpha
NuGet\Install-Package SingularFrameworkCore.Repository.FileSystem.BinaryFile -Version 0.1.0-alpha
<PackageReference Include="SingularFrameworkCore.Repository.FileSystem.BinaryFile" Version="0.1.0-alpha" />
paket add SingularFrameworkCore.Repository.FileSystem.BinaryFile --version 0.1.0-alpha
#r "nuget: SingularFrameworkCore.Repository.FileSystem.BinaryFile, 0.1.0-alpha"
// Install SingularFrameworkCore.Repository.FileSystem.BinaryFile as a Cake Addin #addin nuget:?package=SingularFrameworkCore.Repository.FileSystem.BinaryFile&version=0.1.0-alpha&prerelease // Install SingularFrameworkCore.Repository.FileSystem.BinaryFile as a Cake Tool #tool nuget:?package=SingularFrameworkCore.Repository.FileSystem.BinaryFile&version=0.1.0-alpha&prerelease
SingularFrameworkCore.Repository.FileSystem.BinaryFile
A C# library that provides binary file storage implementation for the SingularFrameworkCore repository interface. This library offers both synchronous and asynchronous implementations for storing string data in binary files.
Features
- Binary File Storage: Simple implementation for storing string data in binary files
- Dual Implementation: Both synchronous (
BinaryFileRepository
) and asynchronous (BinaryFileRepositoryAsync
) versions - CRUD Operations: Full support for Create, Read, Update, and Delete operations
- Path Management: Secure file path handling
- Exception Handling: Custom exceptions for common scenarios
Installation
The package is available on NuGet. To install it, use the following command:
Install-Package SingularFrameworkCore.Repository.FileSystem.BinaryFile
Or using the .NET CLI:
dotnet add package SingularFrameworkCore.Repository.FileSystem.BinaryFile
Usage
Synchronous Implementation
using SingularFrameworkCore.Repository.FileSystem.BinaryFile;
// Create an instance with a file path
var repository = new BinaryFileRepository("path/to/your/file.txt");
// Create
repository.Create("Hello, World!");
// Read
string content = repository.Read();
// Update
repository.Update("Updated content");
// Delete
repository.Delete();
Asynchronous Implementation
using SingularFrameworkCore.Repository.FileSystem.BinaryFile;
// Create an instance with a file path
var repository = new BinaryFileRepositoryAsync("path/to/your/file.txt");
// Create
await repository.Create("Hello, World!");
// Read
string content = await repository.Read();
// Update
await repository.Update("Updated content");
// Delete
await repository.Delete();
Integration with SingularFrameworkCore
This library implements the ISingularCrudRepository<string>
and ISingularCrudAsyncRepository<string>
interfaces from SingularFrameworkCore, making it perfect for use with the Singular pipeline:
var singular = new Singular<MyClass, string>(
new BinaryFileRepository("data.txt"), // or BinaryFileRepositoryAsync
serializer,
preProcessors,
postProcessors
);
Exception Handling
The library includes a custom exception:
BinaryFileRepositoryFileAlreadyExistsException
: Thrown when attempting to create a file that already exists
try
{
repository.Create("content");
}
catch (BinaryFileRepositoryFileAlreadyExistsException ex)
{
// Handle the case where the file already exists
}
Requirements
- .NET Standard 8.0+
- SingularFrameworkCore
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Author
Made by Mohammad Ayaad 
Original Project
- SingularFrameworkCore - The core framework this implementation is built for
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. net9.0 was computed. 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. |
-
net8.0
- SingularFrameworkCore (>= 0.1.0-alpha)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.0-beta | 43 | 2/15/2025 |
0.1.0-alpha | 40 | 1/30/2025 |