C
C#2y ago
Krai

❔ Singleton Pattern

Hi in ioc container we have .AddSingleton() method for singleton lifetimes. My question is when we need create a singleton class? Can't I just save it with dependency injection?
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega2y ago
Singleton pattern instances should generally be avoided, and if you are using DI then there is no need to explicitly implement singleton pattern instances yourself. since you can just use .AddSingleton and be happy :p
Krai
Krai2y ago
Thank you very much 🙏
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ EntityFramework async where possible?So I want to make sure I don't do something stupid here. I'm trying to convert my DbContext-calls t❔ How to make asp mvc Net 6 and React ecommerce multilingual and multi-currency?I can't find anything about it on the Internet I found some readytouse ecommerce in. Net 6 and Rea❔ Compressing an application with dependenciesIs it possible to put an application with all its dependencies into an .exe?Command WPF with viewmodelHello, i'm looking for some help : I'm currently developing an app with wpf using the mvvm model and✅ How do I make an exponent in winforms?I'm trying to make a random math test simulator for finding the roots of a quadratic equation. I'm n❔ Own map with the possibility of embedding points.Hi, I'm looking for a library that in blazor will allow me to create my own map (with my own backgro❔ .NET 6.0 - Nullable Strings with Dapper Model ClassesHey everyone. I have a .NET 6.0 project that uses Dapper to communicate to a database and I have a c❔ Merging two projects togetherGotta merge two projects together but the issue is some of my partners code is running errors when i❔ ✅ Deserializing a JSON array that contains a derived type AND a base type with JSON.NET?I have three classes: ``` ScratchTarget ├─ ScratchScene └─ ScratchSprite ``` `ScratchTarget`❔ Question How can I get the name of the application the user is currently focused on?So I have a .NET 7.0 app, and I want to see if the app the user is focused on is firefox/chrome, and