public static IEnumerable<PropertyInfo> FindProperties(this object source, Regex expression)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
if (expression == null)
{
throw new ArgumentNullException(nameof(expression));
}
return from x in source.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
where expression.IsMatch(x.Name)
select x;
}
}