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})");
示例#5
0
 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);
示例#8
0
 public string DeserializeSpan(BufferArgs readOnlySpan, OutArgs <int> outReadBytes)
 => $"{_names.DeserializeSpan}({readOnlySpan}, out {outReadBytes})";
示例#9
0
 public abstract void DeserializeSpan(CodeNodeBuilder node, BufferArgs readOnlySpan, OutArgs <int> outReadBytes);
示例#10
0
 public abstract void TrySerialize(CodeNodeBuilder node, InArgs <object> target, BufferArgs readOnlySpan, OutArgs <int> outWrittenBytes);
示例#11
0
 public abstract void TryDeserializeSpan(CodeNodeBuilder node, BufferArgs readOnlySpan, OutArgs <int> outReadBytes, OutArgs <object> outResult);
示例#12
0
 public abstract void TryDeserializeSequence(CodeNodeBuilder node, BufferArgs refSequenceCursor, OutArgs <object> outResult);
示例#13
0
 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)));
示例#14
0
 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);
示例#16
0
 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);
示例#18
0
 public string TrySerialize(InArgs <object> target, BufferArgs readOnlySpan, OutArgs <int> outWrittenBytes)
 => $"{_names.TrySerialize}({target}, {readOnlySpan}, out {outWrittenBytes})";
示例#19
0
 public override void TryDeserializeSequence(CodeNodeBuilder node, BufferArgs refSequenceCursor, OutArgs <object> outResult)
 => node.AddPlain(_resolver.GetMethodBody(_nextMethodNames?.TryDeserializeSequence, new TryDeserializeSequenceArgs <TypeSourceArgs>(parent, refSequenceCursor, outResult)));