Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Property() [5/7]

static MemberExpression System.Linq.Expressions.Expression< TDelegate >.Property ( Expression< TDelegate >? expression,
PropertyInfo property )
inlinestaticinherited

Definition at line 3733 of file Expression.cs.

3734 {
3736 MethodInfo methodInfo = property.GetGetMethod(nonPublic: true);
3737 if (methodInfo == null)
3738 {
3739 methodInfo = property.GetSetMethod(nonPublic: true);
3740 if (methodInfo == null)
3741 {
3742 throw Error.PropertyDoesNotHaveAccessor(property, "property");
3743 }
3744 if (methodInfo.GetParametersCached().Length != 1)
3745 {
3746 throw Error.IncorrectNumberOfMethodCallArguments(methodInfo, "property");
3747 }
3748 }
3749 else if (methodInfo.GetParametersCached().Length != 0)
3750 {
3751 throw Error.IncorrectNumberOfMethodCallArguments(methodInfo, "property");
3752 }
3753 if (methodInfo.IsStatic)
3754 {
3755 if (expression != null)
3756 {
3757 throw Error.OnlyStaticPropertiesHaveNullInstance("expression");
3758 }
3759 }
3760 else
3761 {
3762 if (expression == null)
3763 {
3764 throw Error.OnlyStaticPropertiesHaveNullInstance("property");
3765 }
3768 {
3769 throw Error.PropertyNotDefinedForType(property, expression.Type, "property");
3770 }
3771 }
3772 ValidateMethodInfo(methodInfo, "property");
3773 return MemberExpression.Make(expression, property);
3774 }
static void RequiresNotNull(object value, string paramName)
static void RequiresCanRead(Expression expression, string paramName)
static bool IsValidInstanceType(MemberInfo member, Type instanceType)
Definition TypeUtils.cs:157
static void ValidateMethodInfo(MethodInfo method, string paramName)

References System.Linq.Expressions.Error.IncorrectNumberOfMethodCallArguments(), System.Dynamic.Utils.TypeUtils.IsValidInstanceType(), System.Linq.Expressions.MemberExpression.Make(), System.Linq.Expressions.Error.OnlyStaticPropertiesHaveNullInstance(), System.Linq.Expressions.Error.PropertyDoesNotHaveAccessor(), System.Linq.Expressions.Error.PropertyNotDefinedForType(), System.Dynamic.Utils.ExpressionUtils.RequiresCanRead(), System.Dynamic.Utils.ContractUtils.RequiresNotNull(), and System.Linq.Expressions.Expression< TDelegate >.ValidateMethodInfo().