GitXplorerGitXplorer
k

IoC-Container

public
8 stars
1 forks
0 issues

Commits

List of commits on branch master.
Verified
96d4117fcd7100eff62f1e02d071fc6fae4b4d7c

Merge pull request #3 from kolosovpetro/develop

kkolosovpetro committed 3 years ago
Unverified
b187aa998d3bbeb55c1b238d0b8bbaf60117ba40

sonar workflow add

kkolosovpetro committed 3 years ago
Verified
bc47310490fd78568b1f77d0fb9abda3be505408

Merge pull request #2 from kolosovpetro/develop

kkolosovpetro committed 3 years ago
Unverified
7644f71e81e5c311361c6d99d67c5de4706e1e18

workflow fix

kkolosovpetro committed 3 years ago
Unverified
f5bd87d3af866487ab1f5221a23d15c0f23a7bc1

version bump

kkolosovpetro committed 3 years ago
Unverified
2a567366848c42938ba693a051aab8da671a8883

skip duplicates flag

kkolosovpetro committed 3 years ago

README

The README file for this repository.

IoC Container

Description

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

Snippet:

	IBuilder builder = new Builder();
        builder.AddSingleton<ILogger, Logger>();
        builder.AddSingleton<ILoggerService, LoggerService>();
        builder.AddSingleton<IRandomNumber, RandomNumber>();
        var container = builder.Build();
        var loggerService = container.GetInstance<ILoggerService>();
  • 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 <TContract, IService> (done)