/// <summary> Get the value of the property using the get accessor </summary> public static Value GetPropertyValue(Value objectInstance, PropertyInfo propertyInfo, Value[] arguments) { CheckObject(objectInstance, propertyInfo); if (propertyInfo.GetMethod == null) { throw new GetValueException("Property does not have a get method"); } arguments = arguments ?? new Value[0]; Expression objectInstanceExpression = objectInstance != null ? objectInstance.Expression : new EmptyExpression(); List <Expression> argumentExpressions = new List <Expression>(); foreach (Value argument in arguments) { argumentExpressions.Add(argument.Expression); } return(new Value( propertyInfo.Process, new MemberReferenceExpression(objectInstanceExpression, propertyInfo, argumentExpressions.ToArray()), Value.InvokeMethod(objectInstance, propertyInfo.GetMethod, arguments).CorValue )); }
/// <summary> Get the value of the property using the get accessor </summary> public static Value GetPropertyValue(Thread evalThread, Value objectInstance, IProperty propertyInfo, params Value[] arguments) { CheckObject(objectInstance, propertyInfo); if (!propertyInfo.CanGet) { throw new GetValueException("Property does not have a get method"); } return(Value.InvokeMethod(evalThread, objectInstance, propertyInfo.Getter, arguments)); }
/// <summary> Get the value of the property using the get accessor </summary> public static Value GetPropertyValue(Value objectInstance, PropertyInfo propertyInfo, params Value[] arguments) { CheckObject(objectInstance, propertyInfo); if (propertyInfo.GetGetMethod() == null) { throw new GetValueException("Property does not have a get method"); } Value val = Value.InvokeMethod(objectInstance, (DebugMethodInfo)propertyInfo.GetGetMethod(), arguments); return(val); }
/// <summary> Set the value of the property using the set accessor </summary> public static Value SetPropertyValue(Thread evalThread, Value objectInstance, IProperty propertyInfo, Value[] arguments, Value newValue) { CheckObject(objectInstance, propertyInfo); if (!propertyInfo.CanSet) { throw new GetValueException("Property does not have a set method"); } arguments = arguments ?? new Value[0]; Value[] allParams = new Value[1 + arguments.Length]; allParams[0] = newValue; arguments.CopyTo(allParams, 1); return(Value.InvokeMethod(evalThread, objectInstance, propertyInfo.Setter, allParams)); }
/// <summary> Set the value of the property using the set accessor </summary> public static Value SetPropertyValue(Value objectInstance, PropertyInfo propertyInfo, Value[] arguments, Value newValue) { CheckObject(objectInstance, propertyInfo); if (propertyInfo.SetMethod == null) { throw new GetValueException("Property does not have a set method"); } arguments = arguments ?? new Value[0]; Value[] allParams = new Value[1 + arguments.Length]; allParams[0] = newValue; arguments.CopyTo(allParams, 1); return(Value.InvokeMethod(objectInstance, propertyInfo.SetMethod, allParams)); }