Click here to Skip to main content
14,739,851 members
Home » Discussions » C#
   

C#

 
GeneralRe: .Net Core Windows App, using database repositories Pin
Gerry Schmitz5-Sep-20 9:46
mveGerry Schmitz5-Sep-20 9:46 
AnswerRe: .Net Core Windows App, using database repositories Pin
Richard Deeming6-Sep-20 23:30
mveRichard Deeming6-Sep-20 23:30 
GeneralRe: .Net Core Windows App, using database repositories Pin
jkirkerx7-Sep-20 7:58
professionaljkirkerx7-Sep-20 7:58 
GeneralRe: .Net Core Windows App, using database repositories Pin
jkirkerx7-Sep-20 10:14
professionaljkirkerx7-Sep-20 10:14 
GeneralRe: .Net Core Windows App, using database repositories Pin
jkirkerx7-Sep-20 11:29
professionaljkirkerx7-Sep-20 11:29 
GeneralRe: .Net Core Windows App, using database repositories Pin
jkirkerx7-Sep-20 13:12
professionaljkirkerx7-Sep-20 13:12 
Question.NetCore dependency injection and optional params on assembly scanning Pin
Member 148747204-Sep-20 9:17
MemberMember 148747204-Sep-20 9:17 
AnswerRe: .NetCore dependency injection and optional params on assembly scanning Pin
Richard Deeming6-Sep-20 23:23
mveRichard Deeming6-Sep-20 23:23 
If the constructor parameter is optional, it should just work:
public class Foo
{
    public IBar Bar { get; }
    public IBaz Baz { get; }
    public Foo(IBar bar = default, IBaz baz = default) (Bar, Baz) = (bar, baz);
}

...

IServiceCollection services = new ServiceCollection();
services.AddTransient<IBaz, Baz>();
services.AddTransient<Foo>();

IServiceProvider provider = services.BuildServiceProvider();
Foo foo = provider.GetRequiredService<Foo>();

Debug.Assert(foo != null);
Debug.Assert(foo.Baz != null);
Debug.Assert(foo.Bar == null);
It doesn't matter whether you register the services manually or use Scrutor.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

QuestionHow to create a method in a User control Pin
Member 147923934-Sep-20 8:49
MemberMember 147923934-Sep-20 8:49 
AnswerRe: How to create a method in a User control Pin
Mycroft Holmes4-Sep-20 13:08
professionalMycroft Holmes4-Sep-20 13:08 
GeneralRe: How to create a method in a User control Pin
Member 147923935-Sep-20 8:34
MemberMember 147923935-Sep-20 8:34 
AnswerRe: How to create a method in a User control Pin
Ralf Meier4-Sep-20 22:18
professionalRalf Meier4-Sep-20 22:18 
GeneralRe: How to create a method in a User control Pin
Member 147923935-Sep-20 8:33
MemberMember 147923935-Sep-20 8:33 
AnswerRe: How to create a method in a User control Pin
Ralf Meier5-Sep-20 13:11
professionalRalf Meier5-Sep-20 13:11 
GeneralRe: How to create a method in a User control Pin
Member 147923935-Sep-20 13:41
MemberMember 147923935-Sep-20 13:41 
AnswerRe: How to create a method in a User control Pin
Ralf Meier6-Sep-20 3:29
professionalRalf Meier6-Sep-20 3:29 
GeneralRe: How to create a method in a User control Pin
Member 147923936-Sep-20 6:37
MemberMember 147923936-Sep-20 6:37 
GeneralRe: How to create a method in a User control Pin
Ralf Meier6-Sep-20 10:34
professionalRalf Meier6-Sep-20 10:34 
GeneralRe: How to create a method in a User control Pin
Member 147923936-Sep-20 17:25
MemberMember 147923936-Sep-20 17:25 
QuestionCannot Create and Return an Instance of a Class Pin
Liagapi3-Sep-20 22:52
MemberLiagapi3-Sep-20 22:52 
AnswerRe: Cannot Create and Return an Instance of a Class Pin
Richard Deeming3-Sep-20 23:05
mveRichard Deeming3-Sep-20 23:05 
GeneralRe: Cannot Create and Return an Instance of a Class Pin
Richard MacCutchan3-Sep-20 23:29
mveRichard MacCutchan3-Sep-20 23:29 
GeneralRe: Cannot Create and Return an Instance of a Class Pin
Richard Deeming4-Sep-20 4:10
mveRichard Deeming4-Sep-20 4:10 
QuestionProper Error handling Pin
Exoskeletor3-Sep-20 13:11
MemberExoskeletor3-Sep-20 13:11 
AnswerRe: Proper Error handling Pin
Gerry Schmitz3-Sep-20 17:30
mveGerry Schmitz3-Sep-20 17:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.