| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using InABox.Core;
- namespace InABox.Rpc
- {
- public class RpcSaveResult : ISerializeBinary
- {
-
- public Type Type { get; set; }
- public Dictionary<string, object?>[] Deltas { get; set; }
- public RpcSaveResult()
- {
- Deltas = new Dictionary<string, object?>[] { };
- }
-
- public void SerializeBinary(CoreBinaryWriter writer)
- {
- writer.Write(Type.EntityName());
- writer.Write(Deltas.Length);
- foreach (var delta in Deltas)
- {
- writer.Write(delta.Count);
- foreach (var key in delta.Keys)
- {
- writer.Write(key);
- writer.WriteBinaryValue(delta[key]);
- }
- }
- }
- public void DeserializeBinary(CoreBinaryReader reader)
- {
- List<Dictionary<String, object?>> deltas = new List<Dictionary<string, object?>>();
- String typename = reader.ReadString();
- var type = CoreUtils.GetEntityOrNull(typename);
- int deltacount = reader.ReadInt32();
- for (int iDelta = 0; iDelta < deltacount; iDelta++)
- {
- Dictionary<String, object?> delta = new Dictionary<string, object?>();
- int keycount = reader.ReadInt32();
- for (int iKey = 0; iKey < keycount; iKey++)
- {
- var key = reader.ReadString();
- var prop = CoreUtils.GetProperty(type, key);
- var value = reader.ReadBinaryValue(prop.PropertyType);
- delta[key] = value;
- }
- deltas.Add(delta);
- }
- Deltas = deltas.ToArray();
- }
- }
- }
|