Created
July 20, 2012 11:44
-
-
Save DavidArno/3150305 to your computer and use it in GitHub Desktop.
Type<T> example
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
I have a class that is similar to: | |
public class SystemConfiguration<T1, T2, T3, T4, T5> | |
where T1 : ILogger, new() | |
where T2 : IReporter, new() | |
where T3 : IQueue, new() | |
where T4 : IConfiguration, new() | |
where T5 : ILauncher, new() | |
{ | |
public SystemConfiguration() | |
{ | |
var logger = new T1(); | |
var queue = new T3(); | |
var configuration = new T4(); | |
var _systemPart1 = new SystemPart1(logger, configuration); | |
var _systemPart1 = new SystemPart2(queue, configuration); | |
.... | |
What I want to do is: | |
public class SystemConfiguration | |
{ | |
Type<T1> where T1 : ILogger, new() LoggerType { get; set; } | |
Type<T2> where T2 : IReporter, new() ReporterType { get; set; } | |
... | |
} | |
public class SystemSetup | |
{ | |
public SystemSetup(SystemConfiguration systemConfiguration) | |
{ | |
var logger = new systemConfiguration.LoggerType(); | |
var reporter= new systemConfiguration.ReporterType(); | |
... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment