CSHARP_GEPARD Telegram 57
Scoped в Singleton #отдых #архитектура

Я вот помню, на собесах спрашивали - можно ли Scoped звать из Singleton.
Так что, получается, можно или нет?

var provider = new ServiceCollection()
.AddScoped<Scoped>()
.AddSingleton<Singleton>()
.BuildServiceProvider();

provider.GetRequiredService<Singleton>();

public class Scoped
{
public string Say() => "Scoped in Singleton";
}

public class Singleton
{
public Singleton(Scoped scoped)
{
Console.WriteLine($"{scoped.Say()}, World!");
}
}
😁6👍3🤯2



tgoop.com/csharp_gepard/57
Create:
Last Update:

Scoped в Singleton #отдых #архитектура

Я вот помню, на собесах спрашивали - можно ли Scoped звать из Singleton.
Так что, получается, можно или нет?


var provider = new ServiceCollection()
.AddScoped<Scoped>()
.AddSingleton<Singleton>()
.BuildServiceProvider();

provider.GetRequiredService<Singleton>();

public class Scoped
{
public string Say() => "Scoped in Singleton";
}

public class Singleton
{
public Singleton(Scoped scoped)
{
Console.WriteLine($"{scoped.Say()}, World!");
}
}

BY C# Heppard


Share with your friend now:
tgoop.com/csharp_gepard/57

View MORE
Open in Telegram


Telegram News

Date: |

Hashtags are a fast way to find the correct information on social media. To put your content out there, be sure to add hashtags to each post. We have two intelligent tips to give you: A vandalised bank during the 2019 protest. File photo: May James/HKFP. Unlimited number of subscribers per channel Private channels are only accessible to subscribers and don’t appear in public searches. To join a private channel, you need to receive a link from the owner (administrator). A private channel is an excellent solution for companies and teams. You can also use this type of channel to write down personal notes, reflections, etc. By the way, you can make your private channel public at any moment. Telegram channels fall into two types:
from us


Telegram C# Heppard
FROM American