GithubHelp home page GithubHelp logo

778569 / dependency-injection-with-.net-simple-console-app- Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 837 KB

Explore clean, maintainable code with Dependency Injection in .NET. This repository showcases best practices and examples for leveraging DI to enhance software modularity and testability.

C# 100.00%
ccharp console-application dependency-injection

dependency-injection-with-.net-simple-console-app-'s Introduction

Type of Dependency injection

  • Constructor Injection (Inject to Class A contractor)
  • Property Injection (Inject to Class A Property)
  • Method Injection (Inject to Class A Method )

    image

The code snippet you sent me defines a ServiceCollection which is used to register services that can be injected into other parts of the application. The AddSingleton(), AddScoped(), and AddTransient() methods are used to specify the lifetime of the registered services.

  • AddSingleton() registers a service that will be created only once and used throughout the application.
  • AddScoped() registers a service that will be created once per scope. A scope is typically a request or a web session.
  • AddTransient() registers a service that will be created each time it is injected. The specific code you sent me does not register any services, but it shows the basic syntax for how to register services with different lifetimes.

Example -

image

Resule -

image

dependency-injection-with-.net-simple-console-app-'s People

Contributors

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