Code Monkey home page Code Monkey logo

lightweightioccontainer's People

Contributors

simong96 avatar thekbro avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

thekbro jch2k

lightweightioccontainer's Issues

Refactor `Injector`

Decide on a different name than Injector and refactor all its current occurrences.

  • IInjectorContainer
  • InjectorContainer
  • IInjectorInstaller
  • InjectorContainerTest
  • check messages and exceptions
  • comments
  • Documentation

Create example project

Create an example project to see how to use the LightweightIocContainer and to have a project where debugging is made easy.

Allow passing of parameters to registration in an `IIocInstaller`

The user should be able to pass a parameter to the constructor of the registered class from the IIocInstaller. This has to be possible within the fluent registration of the type (similar to OnCreate()).

Initial idea:
Add a function Parameters(params object[] parameters) to IDefaultRegistration<> and pass the given arguments to the ResolveInternal<>() or the CreateInstance<>() method when the type is resolved.

Problem:
If multiple parameters of the same type are passed through different ways (passed directly to Resolve<>() or new Parameters() method), how does the container know when to use which parameter?

Simplify registration

Simplify the registration process in an IIocInstaller:

  • Make IocContainer.Register() private/internal
  • Add Register<>() methods from RegistrationFactory to container
  • Make RegistrationFactory internal
  • Remove IIocContainer parameter from the RegisterFactory<>() methods
  • Call RegistrationFactory methods from their counterpart in the IocContainer
  • Change calls from IIocInstallers

Add `AssemblyInstaller`

Add an AssemblyInstaller that can take all IIocInstallers of an assembly and install them without the user needing to add them specifically.

Rewrite `CreateFactory()` method

Rewrite CreateFactory() method in TypedFactoryRegistration.

Decide how to change it for better readability and maintainability.

See here for problems with the current implementation.

Fix problems in `CreateFactory()` method

Fix the important problems with the CreateFactory() method in TypedFactoryRegistration.
This is related to #4, but in contrary to that issue these are important bugs that need to be fixed as soon as possible.

See here for problems with the current implementation.

Add Multiton Lifestyle

Add Lifestyle Multiton to Lifestyles.

  • add Multiton
  • adapt ResolveInternal() to handle multitons

Add validate method

Add a Validate() method to the IIocContainer that can be called from a test and checks if all registered types in the given installers can be resolved.

Add exception base type

Add a public exception base type with InnerExceptions that can be handled by user applications.

Test NoMatchingConstructorFoundException if the first ctor found is not matching

Test if the NoMatchingConstructorFoundException is working as intended when the first constructor that is found is not matchting but another matching one is found.

NoMatchingConstructorFoundException noMatchingConstructorFoundException = null; //TestMe: Is this thrown when a matching constructor is found but first a non matching one is found?

Can't match argument type with an expected interface type in `ResolveConstructorArguments()`

If an interface type is expected as a constructor parameter, but the given argument is of the type of the implementation, in the function ResolveConstructorArguments() the parameter can't be assigned to the correct parameter.

This happens because we only check for

fittingArgument = argumentsList.FirstOrGiven<object, InternalResolvePlaceholder>(a => a?.GetType() == parameter.ParameterType);

We also have to check for

parameter.ParameterType.IsInstanceOfType(a)

Improve errormessages

e.g. on resolve() if ABC ctor needs IDEF and IGHJ
display something like: could not resolve IABC because IDEF could not be resolved!

Remove non generic Register methods

The non-generic register methods like IIocContainer.Register(Type, Type, Lifestyle) can be removed from the IIocContainer and the RegistrationFactory.

Create nuget package

  • Create nuget package
  • Check for all needed information
  • Certificate?
  • Publish nuget package

Check if constructor can be used without creating arguments

Currently when trying to find a possible constructor, missing arguments are resolved if possible:

ctorParams.Add(Resolve(parameter.ParameterType, null, resolveStack));

Whenever a constructor isn't selected there still might be arguments that get created.
If these arguments are registered as singletons they are created, added to the instances list and might not even be needed.

Try to find an option to check if constructors can be used without creating arguments first. If the constructor is selected the arguments can be created.

Allow registration of multiple interfaces for one type

Allow the registration of multiple interfaces for one registered type, e.g.:

The interface

public interface IFoo : IBar { }

is implemented by

public class Foo : IFoo { }

Users may want to get a IBar or a IFoo and both times need the implementing type Foo.
The registration should look something like this:

container.Register<IBar, IFoo, Foo>();

For registrations with Lifestyle.Transient this could be done by calling IIocContainer.Register<>() multiple times:

container.Register<IBar, Foo>();
container.Register<IFoo, Foo>();

What can be done for registrations with Lifestyle.Singleton? Every Resolve<>() call has to return the same instance of the implemented type.

Add exception when no matching constructor is found

Add an exception that gets thrown when none of the existing constructors match the given or resolvable arguments.

Use the existing try-catch in ResolveConstructorArguments():

catch (Exception ex) //TODO: Decide what exactly to do in this case
{
continue;
}

Create a new exception type that derives from AggregateException and lists the constructors that can not be used.

Steps to create a new version

The following steps should be completed before a new version is released:

  • Update version number in Properties
  • Update version number in AppVeyor settings
  • Create GitHub release
    • upload nuget package to release
    • update release notes for release
    • add fixed issues to release notes
  • publish nuget package to nuget gallery
  • update demo project with new features
  • check for more old version numbers

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.