Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Design Patterns with C# and .NET Core

You're reading from   Hands-On Design Patterns with C# and .NET Core Write clean and maintainable code by using reusable solutions to common software design problems

Arrow left icon
Product type Paperback
Published in Jul 2019
Publisher Packt
ISBN-13 9781789133646
Length 410 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Jeffrey Chilberto Jeffrey Chilberto
Author Profile Icon Jeffrey Chilberto
Jeffrey Chilberto
Gaurav Aroraa Gaurav Aroraa
Author Profile Icon Gaurav Aroraa
Gaurav Aroraa
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Section 1: Essentials of Design Patterns in C# and .NET Core FREE CHAPTER
2. Overview of OOP in .NET Core and C# 3. Modern Software Design Patterns and Principles 4. Section 2: Deep Dive into Utilities and Patterns in .NET Core
5. Implementing Design Patterns - Basics Part 1 6. Implementing Design Patterns - Basics Part 2 7. Implementing Design Patterns - .NET Core 8. Implementing Design Patterns for Web Applications - Part 1 9. Implementing Design Patterns for Web Applications - Part 2 10. Section 3: Functional Programming, Reactive Programming, and Coding for the Cloud
11. Concurrent Programming in .NET Core 12. Functional Programming Practices 13. Reactive Programming Patterns and Techniques 14. Advanced Database Design and Application Techniques 15. Coding for the Cloud 16. Miscellaneous Best Practices 17. Assessments 18. Other Books You May Enjoy

.Net Core service lifetimes

A fundamental concept to understand when working with .Net Core's DI, is service lifetimes. A service lifetime defines how a dependency is managed in regards to how often it is created. As an illustration of this process, think of DI as managing a container of dependencies. Dependency is just a class that the DI knows about, because the class was registered with it. For .Net Core's DI, this is done with the following three methods of IServiceCollection:

  • AddTransient<TService, TImplementation>()
  • AddScoped<TService, TImplementation>()
  • AddSingleton<TService, TImplementation>()

The IServiceCollection interface is a collection of registered service descriptions, basically containing the dependency, and when the DI should supply the dependency. For example, when TService is requested, TImplementation is supplied (that is, injected...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image