Giter Club home page Giter Club logo

abdrakov.container's Introduction

Abdrakov.Solutions logo

Abdrakov.Container

Prism Adapter:

Nuget Nuget License

Prism.Avalonia Adapter:

Nuget Nuget License

About:

A package that provides registrations and resolves of services and other shite in the fast and lightweight container.

Download for WPF with Prism:

.NET CLI:

dotnet add package Abdrakov.Container.PrismAdapter

Package Reference:

<PackageReference Include="Abdrakov.Container.PrismAdapter" Version="*" />

Download for Avalonia with Prism.Avalonia:

.NET CLI:

dotnet add package Abdrakov.Container.AvaloniaPrismAdapter

Package Reference:

<PackageReference Include="Abdrakov.Container.AvaloniaPrismAdapter" Version="*" />

Features:

Attribute injections:

All the registered shite could be resolved via Injection attribute (use the attribute only for properties and fields) like this:

private class NormalClass
{
    [Injection]
    InjectedClass TestClass { get; set; }
    [Injection]
    AnotherInjectedClass _anotherTestClass;
}

Constructor injections:

Parametrised constructors could be used with Abdrakov.Container. For example after registering and resolving the class

private class NormalClass
{
    private InjectedClass _testClass;
    private int _a;
    private string _b;

    public NormalClass(InjectedClass testClass, int a, string b = "awd")
    {
        _testClass = testClass;
        _a = a;
        _b = b;
    }
}

the testClass parameter would be resolved as usual (if it is not registered in the container then an instance of it would be created); the a parameter would have default type value (for Int32 is 0); the b parameter would have its default parameter value (in this case is "awd").

Inheritance injections:

The classed from which Your class is inherited would also be prepared for injections:

private class InjectedClass
{
    internal int A { get; set; }
}

private class BaseClass
{
    [Injection]
    protected InjectedClass TestClass { get; set; }
}

private class NormalClass : BaseClass
{
}

So in this case after NormalClass registration and resolve, the TestClass property would also be injected.

Recursive injections:

There could be two classes that require injection of each other:

private class FirstClass
{
    [Injection]
    SecondClass InjectedClass { get; set; }
}

private class SecondClass
{
    [Injection]
    FirstClass InjectedClass { get; set; }
}

And this would work as expected!

Powered by:

abdrakov.container's People

Contributors

crackanddie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.