Created
March 26, 2013 18:54
-
-
Save jsvnm/5248107 to your computer and use it in GitHub Desktop.
Why are the values in a box? come out of there.
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
private static class Boxed<T> { | |
internal static readonly Converter<object, T> PleaseComeOut = Boxed<T>.Delivers(typeof(T)); | |
private static Converter<object, T> Delivers(Type type) { | |
if (type.IsValueType) return new Converter<object, T>(Boxed<T>.Contents); | |
throw new InvalidOperationException("No thanks"); | |
} | |
private static T Contents(object value) { return (T) value; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment