-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from jcreach/feature/add-keyed-services-support
add keyed services
- Loading branch information
Showing
8 changed files
with
401 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,7 @@ | |
**/.vs | ||
**/bin | ||
**/obj | ||
**/.idea | ||
|
||
# Files | ||
**/*.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
Src/MeleagantDependencyScan.UnitTest/TestServices/HelloWorldKeyedServices.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using MeleagantDependencyScan.Attributes; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace MeleagantDependencyScan.UnitTest.TestServices; | ||
|
||
internal interface IHelloWorldKeyedServices | ||
{ | ||
string SayHiKeyed(string fromWho); | ||
} | ||
|
||
[MeleagantInjectionKeyed(LifeTime = ServiceLifetime.Transient, VisibleFromInterface = true, VisibleAs = [typeof(IHelloWorldKeyedServices)], Key = "TKeyA")] | ||
public class HelloWorldKeyedTransientServicesWithInterfaceKeyA : IHelloWorldKeyedServices | ||
{ | ||
public string SayHiKeyed(string fromWho = "Transient KeyA") | ||
{ | ||
return $"Hello Keyed World {fromWho} with interface"; | ||
} | ||
} | ||
|
||
[MeleagantInjectionKeyed(LifeTime = ServiceLifetime.Transient, VisibleFromInterface = true, VisibleAs = [typeof(IHelloWorldKeyedServices)], Key = "TKeyB")] | ||
public class HelloWorldKeyedTransientServicesWithInterfaceKeyB : IHelloWorldKeyedServices | ||
{ | ||
public string SayHiKeyed(string fromWho = "Transient KeyB") | ||
{ | ||
return $"Hello Keyed World {fromWho} with interface"; | ||
} | ||
} | ||
|
||
[MeleagantInjectionKeyed(LifeTime = ServiceLifetime.Scoped, VisibleFromInterface = true, VisibleAs = [typeof(IHelloWorldKeyedServices)], Key = "SKeyA")] | ||
public class HelloWorldKeyedScopedServicesWithInterfaceKeyA : IHelloWorldKeyedServices | ||
{ | ||
public string SayHiKeyed(string fromWho = "Scoped KeyA") | ||
{ | ||
return $"Hello Keyed World {fromWho} with interface"; | ||
} | ||
} | ||
|
||
[MeleagantInjectionKeyed(LifeTime = ServiceLifetime.Scoped, VisibleFromInterface = true, VisibleAs = [typeof(IHelloWorldKeyedServices)], Key = "SKeyB")] | ||
public class HelloWorldKeyedScopedServicesWithInterfaceKeyB : IHelloWorldKeyedServices | ||
{ | ||
public string SayHiKeyed(string fromWho = "Scoped KeyB") | ||
{ | ||
return $"Hello Keyed World {fromWho} with interface"; | ||
} | ||
} | ||
|
||
[MeleagantInjectionKeyed(VisibleFromInterface = true, VisibleAs = [typeof(IHelloWorldKeyedServices)], Key = "SiKeyA")] | ||
public class HelloWorldKeyedSingletonServicesWithInterfaceKeyA : IHelloWorldKeyedServices | ||
{ | ||
public string SayHiKeyed(string fromWho = "Singleton KeyA") | ||
{ | ||
return $"Hello Keyed World {fromWho} with interface"; | ||
} | ||
} | ||
|
||
[MeleagantInjectionKeyed(VisibleFromInterface = true, VisibleAs = [typeof(IHelloWorldKeyedServices)], Key = "SiKeyB")] | ||
public class HelloWorldKeyedSingletonServicesWithInterfaceKeyB : IHelloWorldKeyedServices | ||
{ | ||
public string SayHiKeyed(string fromWho = "Singleton KeyB") | ||
{ | ||
return $"Hello Keyed World {fromWho} with interface"; | ||
} | ||
} |
Oops, something went wrong.