Example #1
0
            /// <summary>
            /// Deserialise an API call from JSON
            /// </summary>
            /// <param name="apiArr">The serialised call data</param>
            /// <param name="trace">The trace the call belongs to</param>
            /// <param name="apiObj">The resulting API object</param>
            /// <returns></returns>
            public static bool TryDeserialise(JArray apiArr, TraceRecord trace, out APICALL?apiObj)
            {
                apiObj = null;

                if (apiArr[0].Type is not JTokenType.Date)
                {
                    return(false);
                }
                DateTime graphConstructed = apiArr[0].ToObject <DateTime>();

                ProtoGraph?graph = trace.GetProtoGraphByTime(graphConstructed);

                if (graph is null)
                {
                    return(false);
                }

                apiObj = new APICALL(graph)
                {
                    Node    = graph.NodeList[apiArr[1].ToObject <int>()],
                    Index   = apiArr[2].ToObject <int>(),
                    Repeats = apiArr[3].ToObject <ulong>(),
                    UniqID  = apiArr[4].ToObject <uint>()
                };

                if (apiArr[5] is not null)
                {
                    if (!DeserialiseEffects(apiArr[5], apiObj))
                    {
                        return(false);
                    }
                }

                return(true);
            }