Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kolosovpetro/ioc-container

Simple Reflection-driven Inversion of Control container.
https://github.com/kolosovpetro/ioc-container

dependency-injection inversion-of-control ioc ioc-container

Last synced: 2 months ago
JSON representation

Simple Reflection-driven Inversion of Control container.

Awesome Lists containing this project

README

        

# IoC Container

## Description

Simple IoC Container. This container consists of the following layers:

Snippet:

```cs
IBuilder builder = new Builder();
builder.AddSingleton();
builder.AddSingleton();
builder.AddSingleton();
var container = builder.Build();
var loggerService = container.GetInstance();
```

- Builder: abstraction over container, builds container, registers types and returns concrete container.
- Container: has a methods in order to register types and returns concrete instance, which implements TConctract
- Service: entity with type properties, concrete implementation of TContract, and enum property lifetime

## To Do

- Implement following responsibilities:
- Builder -- builds container,
- Container -- registers type and gives an instance from service
- Service -- contains instance, lifetime, types.
- ~~Create abstraction layer to reduce cast~~ (done)
- Create and throw custom exceptions:
- InvalidTypeException:
- ~~to be thrown when TImplementation doesn't implement TContract~~ (done)
- TypeAlreadyRegisteredException:
- ~~to be thrown when user try to add TConctract which is already registered~~ (done)
- TypeNotFoundException:
- ~~to be thrown if TConctract is not registered in container~~ (done)
- ~~Perform tests for singleton and transient objects~~ (done)
- ~~Implement logic such that will provide always new instance in Transient, and to keep instance in case if Singleton~~ (done)
- ~~Unite all logics under one dictionary ~~ (done)