Carsillas
Carsillas
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
74 replies
CC#
Created by Carsillas on 11/1/2022 in #help
out ref local?
Seems I am able to do this:
ref int Test1(){
return ref ints[1];
}
ref int Test1(){
return ref ints[1];
}
but not this:
void Test2(out ref int a){
a = ref ints[1];
}
void Test2(out ref int a){
a = ref ints[1];
}
is there some syntax im missing or is this just not possible?
11 replies
CC#
Created by Carsillas on 10/27/2022 in #help
Dependency injection questions
I've been learning dependency injection in a non-web-api environment (tagging as asp.net anyways since it's pretty related I feel) and have a few questions: 1. Is there a proper way to bind an interface to a hosted service, is this something I should just in general avoid? If so why? The situation in question is I want to bind a "network service" that will handle transporting messages over the network, but I don't necessarily always want it to have the same transport, was hoping to abstract this to an interface. It still would be nice to have it hosted so it can do some setup. 2. Is it standard practice for hosted services to be in charge of creating scopes? If so, is it normal that examples I've seen online use things like GetRequiredService which seems more like service locator pattern? 3. I have found that there is no way to swap out implementations for different scopes, is there a usual way of achieving something similar? For one scope I want to have IFoo bound to Foo and in another scope I want to have IFoo bound to Bar (these would specifically be Scoped services, not transient/singleton/hosted)
1 replies