public override void InvokeMethod(NetMethodInfo methodInfo, NetInstance target, NetVariantVector parameters, NetVariant result) { var handle = (GCHandle)target.GetGCHandle(); var o = handle.Target; List <object> methodParameters = null; if (parameters.Count > 0) { methodParameters = new List <object>(); foreach (var parameterInstance in parameters) { object v = null; Unpackvalue(ref v, parameterInstance); methodParameters.Add(v); } } var r = o.GetType() .GetMethod(methodInfo.GetMethodName(), BindingFlags.Instance | BindingFlags.Public) .Invoke(o, methodParameters?.ToArray()); if (result == null) { // this method doesn't have return type } else { PackValue(ref r, result); } }
public override void ReadProperty(NetPropertyInfo propertyInfo, NetInstance target, NetVariant result) { var handle = (GCHandle)target.GetGCHandle(); var o = handle.Target; var value = o.GetType() .GetProperty(propertyInfo.GetPropertyName(), BindingFlags.Instance | BindingFlags.Public) .GetValue(o); PackValue(ref value, result); }
public override void WriteProperty(NetPropertyInfo propertyInfo, NetInstance target, NetVariant value) { base.WriteProperty(propertyInfo, target, value); var handle = (GCHandle)target.GetGCHandle(); var o = handle.Target; var pInfo = o.GetType() .GetProperty(propertyInfo.GetPropertyName(), BindingFlags.Instance | BindingFlags.Public); object newValue = null; Unpackvalue(ref newValue, value); pInfo.SetValue(o, newValue); }