https://github.com/beyondnetcode/shell.factory
Configuration-driven Factory pattern library for .NET with fluent API, DI integration, interceptors, and type-safe object creation.
https://github.com/beyondnetcode/shell.factory
aop csharp factory-method-pattern factory-pattern net
Last synced: 3 days ago
JSON representation
Configuration-driven Factory pattern library for .NET with fluent API, DI integration, interceptors, and type-safe object creation.
- Host: GitHub
- URL: https://github.com/beyondnetcode/shell.factory
- Owner: beyondnetcode
- License: mit
- Created: 2026-05-30T12:03:14.000Z (19 days ago)
- Default Branch: main
- Last Pushed: 2026-06-07T17:08:15.000Z (11 days ago)
- Last Synced: 2026-06-07T19:08:30.780Z (11 days ago)
- Topics: aop, csharp, factory-method-pattern, factory-pattern, net
- Language: C#
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.en.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# BeyondNet.Factory
English | Español
BeyondNet.Factory is a .NET library aimed at improving the factory and abstract factory patterns by introducing configuration-driven behavior. It enables developers to create structured factories that simplify object instantiation across different .NET applications.
## Features
- **Configuration-Driven Factory**: Create factories with setup records for cleaner instantiation
- **Fluent API**: Chain configuration with an expressive builder interface
- **Interceptor Support**: Add custom logic before/after object creation
- **DI Integration**: Seamless integration with Microsoft.Extensions.DependencyInjection
- **Generic Support**: Work with generic types for better type safety
- **Extensible**: Easily add custom setup sources and interceptors
## Architecture
The library is organized into modular packages:
```
BeyondNetCode.Shell.Factory # Core factory patterns
BeyondNetCode.Shell.Factory.Installer # DI extension methods
```
## Installation
```bash
# Core library
dotnet add package BeyondNetCode.Shell.Factory
# DI installer
dotnet add package BeyondNetCode.Shell.Factory.Installer
```
## Usage
### Define a Factory Record
```csharp
public interface IDoSomething
{
string DoIt(string name);
}
public class DoSomething : IDoSomething
{
public string DoIt(string name) => $"Hello, {name}!";
}
```
### Configure and Use
```csharp
// Using fluent API
var factory = new FactorySetupCreateBuilder()
.Create()
.When(c => c.Age > 18)
.Build();
var service = factory.Create();
var result = service.DoIt("World"); // "Hello, World!"
```
### Register with DI
```csharp
services.AddFactory(factory =>
{
factory.Create()
.When(c => c.Age > 18)
.Create()
.When(c => c.Age <= 18);
});
```
### Interceptors
```csharp
public class MyInterceptor : AbstractFactoryInterceptor
{
public override void OnBeforeCreate(Type type, object[] args)
{
Console.WriteLine($"Creating: {type.Name}");
}
}
```
## Testing
```bash
dotnet test
```
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for GitFlow workflow and coding standards.
## Versioning
See [VERSIONING.md](VERSIONING.md) for SemVer strategy.
## License
MIT - See [LICENSE](LICENSE)
## Acknowledgments
See [DISCLAIMER.md](DISCLAIMER.md) for original code authorship.