TinyFactory 1.1.3

Small and simple factory. TinyFactory is ready to store and instantiate simple classes.
This factory can create new instances of classes or store their references to them.

There is a newer version of this package available.
See the version list below for details.
Install-Package TinyFactory -Version 1.1.3
dotnet add package TinyFactory --version 1.1.3
<PackageReference Include="TinyFactory" Version="1.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TinyFactory --version 1.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TinyFactory, 1.1.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install TinyFactory as a Cake Addin
#addin nuget:?package=TinyFactory&version=1.1.3

// Install TinyFactory as a Cake Tool
#tool nuget:?package=TinyFactory&version=1.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

TinyFactory

Small and simple factory. TinyFactory is ready to store and instantiate simple classes.

This factory can create new instances of classes or store their references to them.

TinyFactory knows how to inject dependencies through the constructor

Build status

Quick start

Create your a class factory and extend from TinyFactory:

public class Factory : TinyFactory
{
    private static Factory _instace;
    private static object locker = new object();
    private Factory() : base() { }

    protected override void ConfigureFactory(IFactoryCollection collection)
    {
        collection.AddSingleton<IRepository, UserRepository>();
        collection.AddTransient<IRepositoryConfig, Config>();
    }

    public static Factory GetFactory()
    {
        lock(locker)
        {
            if (_instace == null) _instace = new Factory();
            return _instace;
        }
    }

    public static T Resolve<T>() where T: class => GetFactory().Get<T>();

}

And using this class in your code:

var repo = Factory.Resolve<IRepository>();

See more in demo project

TinyFactory

Small and simple factory. TinyFactory is ready to store and instantiate simple classes.

This factory can create new instances of classes or store their references to them.

TinyFactory knows how to inject dependencies through the constructor

Build status

Quick start

Create your a class factory and extend from TinyFactory:

public class Factory : TinyFactory
{
    private static Factory _instace;
    private static object locker = new object();
    private Factory() : base() { }

    protected override void ConfigureFactory(IFactoryCollection collection)
    {
        collection.AddSingleton<IRepository, UserRepository>();
        collection.AddTransient<IRepositoryConfig, Config>();
    }

    public static Factory GetFactory()
    {
        lock(locker)
        {
            if (_instace == null) _instace = new Factory();
            return _instace;
        }
    }

    public static T Resolve<T>() where T: class => GetFactory().Get<T>();

}

And using this class in your code:

var repo = Factory.Resolve<IRepository>();

See more in demo project

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.0 79 1/28/2021
1.1.3 140 11/17/2020
1.1.2 134 9/24/2020