Skip to content

Instantly share code, notes, and snippets.

@droyad
Last active December 24, 2015 15:59
Show Gist options
  • Select an option

  • Save droyad/6824660 to your computer and use it in GitHub Desktop.

Select an option

Save droyad/6824660 to your computer and use it in GitHub Desktop.
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