Skip to content

Instantly share code, notes, and snippets.

@JeffreyZhao
Created May 28, 2014 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffreyZhao/f3d101a39d5a839665cf to your computer and use it in GitHub Desktop.
Save JeffreyZhao/f3d101a39d5a839665cf to your computer and use it in GitHub Desktop.
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);
}
}
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