public static object[] GetArrayParams(BinaryReader br) { int size = br.ReadInt32(); var res = new object[size]; for (int i = 0; i < res.Length; i++) { res[i] = WorkWithVariant.GetObject(br); } return(res); }
public static void CallBinaryOperation(BinaryReader br, BinaryWriter bw) { if (!GetAW(br, bw, out var autoWrap)) { return; } var expressionType = (ExpressionType)br.ReadByte(); if (!OperatorInfo.OperatorMatches.TryGetValue(expressionType, out var methodName)) { SetError($"Нет соответствия {expressionType} имени метода", bw); return; } object param2 = WorkWithVariant.GetObject(br); var args = new[] { autoWrap.Object, param2 }; CallStaticMethod(bw, autoWrap.Type, methodName, args); }
public static void SetPropVal(BinaryReader br, BinaryWriter bw) { if (!GetAW(br, bw, out var autoWrap)) { return; } string propertyName = br.ReadString(); object result = WorkWithVariant.GetObject(br); var res = autoWrap.TrySetMember(propertyName, result, out var error); if (!res) { SetError(error, bw); } else { bw.Write(true); WorkWithVariant.WriteObject(null, bw); } }
public static void SetIndex(BinaryReader br, BinaryWriter bw) { if (!GetAW(br, bw, out var autoWrap)) { return; } var indexes = GetArrayParams(br); object[] Params = new object[indexes.Length + 1]; var value = WorkWithVariant.GetObject(br); string methodName = "set_Item"; if (typeof(Array).IsAssignableFrom(autoWrap.Type)) { methodName = "SetValue"; indexes.CopyTo(Params, 1); Params[0] = value; } else { indexes.CopyTo(Params, 0); Params[Params.Length - 1] = value; } var changeParams = new List <int>(); var res = autoWrap.TryInvokeMember(methodName, Params, out var result, changeParams, out var error); if (!res) { SetError(error, bw); } else { bw.Write(true); WorkWithVariant.WriteObject(null, bw); } }