Giter Club home page Giter Club logo

dependencyresolver's Introduction

DependencyResolver

A simple dependency injection framework to demonstrate the core functionality such as registration and resolving of dependency trees.

Download and Install DependencyResolver

This library is available on NuGet: https://www.nuget.org/packages/DependencyResolver.NET Use the following command to install DependencyResolver.NET using NuGet package manager console:

PM> Install-Package DependencyResolver.NET

You can use this library in any .NET project which is compatible to .NET Framework 4.5, .NET Standard 2.0 and higher.

How it use DependencyResolver

The DependencyResolver provides two basic methods: Register and Resolve. Register allows to map abstractions to implementations at bootstrap time of an application. These registrations are sometimes also called services, service mappings or dependencies. Later, at runtime of the application, the Resolve method is used to create instances for the registered services.

// Create a new dependency injection container
var resolver = new Resolver();

// Register dependencies
resolver.Register<ILogger, ConsoleLogger>();
resolver.Register<IPaymentService, PaymentService>();
resolver.Register<IPaymentServiceConfiguration, PaymentServiceConfiguration>();

// Resolve dependencies
var paymentService = resolver.Resolve<IPaymentService>();
paymentService.Charge(99m, new MasterCard());

Disclaimer

Do not use DependencyResolver in production code!
Use one of the well-known DI frameworks instead: Autofac, Unity, Ninject.

Links

Original Source & Credits
http://www.pashov.net/code/dependency-injection-hood/

Autofac
https://autofac.org/

Unity Container
https://github.com/unitycontainer

Ninject
http://www.ninject.org/

Dependency Injection in ASP.NET Core
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-2.2

dependencyresolver's People

Contributors

thomasgalliker avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.