diff --git a/ICD.Common.Utils/AttributeUtils.cs b/ICD.Common.Utils/AttributeUtils.cs index beda60c..74dc221 100644 --- a/ICD.Common.Utils/AttributeUtils.cs +++ b/ICD.Common.Utils/AttributeUtils.cs @@ -119,7 +119,7 @@ namespace ICD.Common.Utils if (s_CachedTypes.Contains(type)) return; - + s_CachedTypes.Add(type); try @@ -214,6 +214,28 @@ namespace ICD.Common.Utils return s_AttributeToTypeCache[attribute]; } + /// + /// Returns the properties on the given instance with property attributes of the given type. + /// + /// + /// + /// + /// + public static IEnumerable GetProperties(object instance, bool inherit) + { + if (instance == null) + throw new ArgumentNullException("instance"); + + return instance.GetType() +#if SIMPLSHARP + .GetCType() +#else + .GetTypeInfo() +#endif + .GetProperties() + .Where(p => ReflectionExtensions.GetCustomAttributes(p, inherit).Any()); + } + #endregion } }