Last active
December 24, 2015 15:59
-
-
Save droyad/6824660 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| namespace IBM | |
| { | |
| public class DeepThought | |
| { | |
| private static void Main(string[] args) | |
| { | |
| new DeepThought("What is the answer to life, the universe and everything?"); | |
| } | |
| private DeepThought(Setting<QuestionConfigurationSetting, string> question) | |
| { | |
| string s = question; | |
| } | |
| } | |
| public class QuestionConfigurationSetting : ConfigurationSetting<string> | |
| { | |
| } | |
| public class AnswerConfigurationSetting : ConfigurationSetting<int> | |
| { | |
| } | |
| public class Setting<TNamed, T> where TNamed : ConfigurationSetting<T>, new() | |
| { | |
| private readonly TNamed _namedSetting; | |
| public Setting(TNamed namedSetting) | |
| { | |
| _namedSetting = namedSetting; | |
| } | |
| public static implicit operator T(Setting<TNamed, T> setting) | |
| { | |
| return setting._namedSetting.Value; | |
| } | |
| public static implicit operator Setting<TNamed, T>(T value) | |
| { | |
| return new Setting<TNamed, T>(new TNamed() { Value = value }); | |
| } | |
| } | |
| public class ConfigurationSetting<T> | |
| { | |
| public T Value { get; set; } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment