Last active
August 29, 2015 14:07
-
-
Save hagbarddenstore/7695d524ecc2ad64bb2b 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 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