public static void SerializeSnapshot(global::Improbable.Interest.Snapshot snapshot, global::Improbable.Worker.CInterop.SchemaObject obj) { foreach (var keyValuePair in snapshot.ComponentInterest) { var mapObj = obj.AddObject(1); mapObj.AddUint32(1, keyValuePair.Key); global::Improbable.ComponentInterest.Serialization.Serialize(keyValuePair.Value, mapObj.AddObject(2)); } }
public static global::Improbable.Interest.Snapshot DeserializeSnapshot(global::Improbable.Worker.CInterop.SchemaObject obj) { var component = new global::Improbable.Interest.Snapshot(); { var map = new global::System.Collections.Generic.Dictionary <uint, global::Improbable.ComponentInterest>(); var mapSize = obj.GetObjectCount(1); component.ComponentInterest = map; for (var i = 0; i < mapSize; i++) { var mapObj = obj.IndexObject(1, (uint)i); var key = mapObj.GetUint32(1); var value = global::Improbable.ComponentInterest.Serialization.Deserialize(mapObj.GetObject(2)); map.Add(key, value); } } return(component); }
public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj, ref global::Improbable.Interest.Snapshot snapshot) { var obj = updateObj.GetFields(); { var mapSize = obj.GetObjectCount(1); var isCleared = updateObj.IsFieldCleared(1); if (mapSize > 0 || isCleared) { snapshot.ComponentInterest.Clear(); } for (var i = 0; i < mapSize; i++) { var mapObj = obj.IndexObject(1, (uint)i); var key = mapObj.GetUint32(1); var value = global::Improbable.ComponentInterest.Serialization.Deserialize(mapObj.GetObject(2)); snapshot.ComponentInterest.Add(key, value); } } }