Skip to content

Instantly share code, notes, and snippets.

@ArtemAvramenko
Created August 5, 2015 18:59
Show Gist options
  • Save ArtemAvramenko/65062e72e6c7948c1bf0 to your computer and use it in GitHub Desktop.
Save ArtemAvramenko/65062e72e6c7948c1bf0 to your computer and use it in GitHub Desktop.
public static class AnonymousTypeHelper
{
public static T Cast<T>(T typeHolder, object x)
{
return (T)x;
}
public static T GetNull<T>(T typeHolder) where T : class
{
return null;
}
public static Dictionary<TKey, TValue> CreateDictionary<TKey, TValue>(TKey keyTypeHolder, TValue valueTypeHolder)
{
return new Dictionary<TKey, TValue>();
}
public static List<TValue> CreateList<TValue>(TValue valueTypeHolder)
{
return new List<TValue>();
}
public static IQueryable<TValue> GetNullIQueryable<TValue>(TValue valueTypeHolder)
{
return (IQueryable<TValue>)null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment