Skip to content

beyondnetcode/Shell.Factory

Repository files navigation

BeyondNet.Factory

A configuration-driven Factory pattern library for .NET

🇬🇧 English | 🇪🇸 Español

NuGet Build


Welcome to BeyondNet.Factory! A .NET library aimed at improving the factory and abstract factory patterns by introducing configuration-driven behavior.

Installation

NuGet Packages

# Core factory library
dotnet add package BeyondNetCode.Shell.Factory

# Dependency Injection installer
dotnet add package BeyondNetCode.Shell.Factory.Installer

Packages Overview

Package Description NuGet
BeyondNetCode.Shell.Factory Core factory patterns with fluent API link
BeyondNetCode.Shell.Factory.Installer Microsoft.Extensions.DependencyInjection extensions link

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

Quick Start

Define a Factory Record

public interface IDoSomething
{
    string DoIt(string name);
}

public class DoSomething : IDoSomething
{
    public string DoIt(string name) => $"Hello, {name}!";
}

Configure and Use

// Using fluent API
var factory = new FactorySetupCreateBuilder<IFactory>()
    .Create<DoSomething>()
    .When<Criteria>(c => c.Age > 18)
    .Build();

var service = factory.Create<DoSomething>();
var result = service.DoIt("World"); // "Hello, World!"

Register with DI

services.AddFactory(factory =>
{
    factory.Create<DoSomething>()
        .When<Criteria>(c => c.Age > 18)
        .Create<DoSomethingLessThan18>()
        .When<Criteria>(c => c.Age <= 18);
});

Documentation

For detailed documentation, see the language-specific README files:

Migration from Ums.Shell.Factory

If you were using Ums.Shell.Factory, update your NuGet references:

# Before (Ums.Shell.Factory)
dotnet add package Ums.Shell.Factory

# After (BeyondNetCode.Shell.Factory)
dotnet add package BeyondNetCode.Shell.Factory

Update namespaces in your code:

// Before
using Ums.Shell.Factory;

// After
using BeyondNetCode.Shell.Factory;

Contributing

See CONTRIBUTING.md for GitFlow workflow, commit conventions, and coding standards.

Versioning

See VERSIONING.md for SemVer strategy and release process.

License

Licensed under the MIT License. See LICENSE for details.

Acknowledgments

See DISCLAIMER.md for original code authorship attribution.

About

Configuration-driven Factory pattern library for .NET with fluent API, DI integration, interceptors, and type-safe object creation.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages