-
-
Save JeffreyZhao/f3d101a39d5a839665cf to your computer and use it in GitHub Desktop.
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
public class TicksToDateTimeCaller { | |
private static DateTime TicksToDateTime(long ticks) { | |
return new DateTime(ticks); | |
} | |
public TResult Call<T, TResult>(T arg) { | |
return (TResult)(object)TicksToDateTime((long)(object)arg); | |
} | |
} |
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
public class TicksToDateTimeCaller { | |
private static class Cache<T, TResult> { | |
public static Func<T, TResult> Call; | |
} | |
private static DateTime TicksToDateTime(long ticks) { | |
return new DateTime(ticks); | |
} | |
static TicksToDateTimeCaller() { | |
Cache<long, DateTime>.Call = TicksToDateTime; | |
} | |
public TResult Call<T, TResult>(T arg) { | |
return Cache<T, TResult>.Call(arg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment