Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Last active August 29, 2015 14:07
Show Gist options
  • Save hagbarddenstore/7695d524ecc2ad64bb2b to your computer and use it in GitHub Desktop.
Save hagbarddenstore/7695d524ecc2ad64bb2b to your computer and use it in GitHub Desktop.
public static class CachedReflector
{
private static readonly Dictionary<Type, IEnumerable<PropertyInfo>> _cachedProperties = new Dictionary<Type, IEnumerable<PropertyInfo>>();
public static IEnumerable<PropertyInfo> GetProperties(Type type)
{
IEnumerable<PropertyInfo> properties;
if (!_cachedProperties.TryGetValue(type, out properties))
{
properties = type.GetProperties();
_cachedProperties.Add(type, properties);
}
return properties;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment