public override void TrySerialize(CodeNodeBuilder node, InArgs <object> target, BufferArgs readOnlySpan, OutArgs <int> outWrittenBytes) => node.Return($"{MemberMethod.TrySerializeState(0)} ({parent}, {target}, {readOnlySpan}, out {outWrittenBytes})");
private void ParseArguments() { // Get input paramter names and output parameter names. ParameterInfo[] pis = methodCall.MethodBase.GetParameters(); List<int> oais = new List<int>(); int i = 0; foreach (ParameterInfo pi in pis) { // in-arguments if (IsInArg(pi)) { inArgNames.Add(pi.Name); inArgTypes.Add(pi.ParameterType); hasInArg = true; } // out-arguments if (IsOutArg(pi)) { var defaultValue = pi.GetCustomAttributes(typeof(DefaultValueAttribute), false) as DefaultValueAttribute[]; var outArg = new OutArgs(pi.Name, null, pi.ParameterType); outArg.DefaultValue = (defaultValue.Length > 0) ? defaultValue[0].DefaultValue : null; outArgs.Add(outArg); outArgTypes.Add(pi.ParameterType); hasOutArg = true; oais.Add(i); } i++; // arg position. } outArgIndexes = oais.ToArray(); // return value MethodInfo mi = (MethodInfo)(methodCall.MethodBase); if (mi.ReturnType != typeof(void)) { ParameterInfo pi = mi.ReturnParameter; var outArg = new OutArgs("Return Value", null, pi.ParameterType); var defaultValue = mi.GetCustomAttributes(typeof(DefaultValueAttribute), false) as DefaultValueAttribute[]; outArg.DefaultValue = (defaultValue.Length > 0) ? defaultValue[0].DefaultValue : null; outArgs.Insert(0, outArg); retValType = pi.ParameterType; hasReturnVal = true; } // The input parameter count should equal the count of the method type. if (inArgNames.Count != methodCall.InArgCount) { throw new InvalidOperationException( String.Format("Calling '{0}' with {1} input paramters which doesn't equal to expected count: {2}.", methodCall.MethodName, methodCall.InArgCount, inArgNames.Count)); } }
public override void TryDeserializeSequence(CodeNodeBuilder node, BufferArgs refSequenceCursor, OutArgs <object> outResult) => node.Return($"{MemberMethod.TryDeserializeState(0)}({parent}, ref {refSequenceCursor}, out {outResult})");
public override void TryDeserializeSpan(CodeNodeBuilder node, BufferArgs readOnlySpan, OutArgs <int> outReadBytes, OutArgs <object> outResult) => node.Return($"{MemberMethod.TryDeserializeState(0)}({parent}, {readOnlySpan}, out {outReadBytes}, out {outResult})");
public override void DeserializeSpan(CodeNodeBuilder node, BufferArgs readOnlySpan, OutArgs <int> outReadBytes) => node.AddPlain(_resolver.GetMethodBody(_nextMethodNames?.TryDeserializeSpan, new DeserializeSpanArgs <TypeSourceArgs>(parent, readOnlySpan, outReadBytes)));
public override void TrySerialize(CodeNodeBuilder node, InArgs <object> target, BufferArgs readOnlySpan, OutArgs <int> outWrittenBytes) => _body.TrySerialize(node, target, readOnlySpan, outWrittenBytes);
public override void DeserializeSpan(CodeNodeBuilder node, BufferArgs readOnlySpan, OutArgs <int> outReadBytes) => _body.DeserializeSpan(node, readOnlySpan, outReadBytes);
public string DeserializeSpan(BufferArgs readOnlySpan, OutArgs <int> outReadBytes) => $"{_names.DeserializeSpan}({readOnlySpan}, out {outReadBytes})";
public abstract void DeserializeSpan(CodeNodeBuilder node, BufferArgs readOnlySpan, OutArgs <int> outReadBytes);
public abstract void TrySerialize(CodeNodeBuilder node, InArgs <object> target, BufferArgs readOnlySpan, OutArgs <int> outWrittenBytes);
public abstract void TryDeserializeSpan(CodeNodeBuilder node, BufferArgs readOnlySpan, OutArgs <int> outReadBytes, OutArgs <object> outResult);
public abstract void TryDeserializeSequence(CodeNodeBuilder node, BufferArgs refSequenceCursor, OutArgs <object> outResult);
public override void TrySerialize(CodeNodeBuilder node, InArgs <object> target, BufferArgs readOnlySpan, OutArgs <int> outWrittenBytes) => node.AddPlain(_resolver.GetMethodBody(_nextMethodNames?.TrySerialize, new TrySerializeArgs <TypeSourceArgs>(parent, target, readOnlySpan, outWrittenBytes)));
public string TryDeserializeSpan(BufferArgs readOnlySpan, OutArgs <int> outReadBytes, OutArgs <object> outResult) => $"{_names.TryDeserializeSpan}({readOnlySpan}, out {outReadBytes}, out {outResult})";
public override void TryDeserializeSequence(CodeNodeBuilder node, BufferArgs refSequenceCursor, OutArgs <object> outResult) => _body.TryDeserializeSequence(node, refSequenceCursor, outResult);
public string TryDeserializeSequence(BufferArgs refSequenceCursor, OutArgs <object> outResult) => $"{_names.TryDeserializeSequence}(ref {refSequenceCursor}, out {outResult})";
public override void TryDeserializeSpan(CodeNodeBuilder node, BufferArgs readOnlySpan, OutArgs <int> outReadBytes, OutArgs <object> outResult) => _body.TryDeserializeSpan(node, readOnlySpan, outReadBytes, outResult);
public string TrySerialize(InArgs <object> target, BufferArgs readOnlySpan, OutArgs <int> outWrittenBytes) => $"{_names.TrySerialize}({target}, {readOnlySpan}, out {outWrittenBytes})";
public override void TryDeserializeSequence(CodeNodeBuilder node, BufferArgs refSequenceCursor, OutArgs <object> outResult) => node.AddPlain(_resolver.GetMethodBody(_nextMethodNames?.TryDeserializeSequence, new TryDeserializeSequenceArgs <TypeSourceArgs>(parent, refSequenceCursor, outResult)));