mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
526 B
20 lines
526 B
using System; |
|
using System.Linq.Expressions; |
|
using System.Reflection; |
|
|
|
namespace ErsatzTV |
|
{ |
|
public static partial class Validators |
|
{ |
|
private static string GetMemberName<T, T2>(Expression<Func<T, T2>> expression) |
|
{ |
|
var member = expression.Body as MemberExpression; |
|
if (member?.Member is PropertyInfo propertyInfo) |
|
{ |
|
return propertyInfo.Name; |
|
} |
|
|
|
throw new ArgumentException("Expression is not a property"); |
|
} |
|
} |
|
}
|
|
|