public static global::Improbable.DependentSchema.DependentComponent.Update DeserializeUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj) { var update = new global::Improbable.DependentSchema.DependentComponent.Update(); var obj = updateObj.GetFields(); if (obj.GetObjectCount(1) == 1) { update.A = global::Improbable.TestSchema.ExhaustiveRepeatedData.Serialization.Deserialize(obj.GetObject(1)); } if (obj.GetEnumCount(2) == 1) { update.B = (global::Improbable.TestSchema.SomeEnum)obj.GetEnum(2); } { var isCleared = updateObj.IsFieldCleared(3); if (isCleared) { update.C = new global::Improbable.Gdk.Core.Option <global::Improbable.TestSchema.SomeEnum?>(new global::Improbable.TestSchema.SomeEnum?()); } else if (obj.GetEnumCount(3) == 1) { update.C = new global::Improbable.Gdk.Core.Option <global::Improbable.TestSchema.SomeEnum?>((global::Improbable.TestSchema.SomeEnum)obj.GetEnum(3)); } } { var listSize = obj.GetObjectCount(4); var isCleared = updateObj.IsFieldCleared(4); if (listSize > 0 || isCleared) { update.D = new global::Improbable.Gdk.Core.Option <global::System.Collections.Generic.List <global::Improbable.TestSchema.SomeType> >(new global::System.Collections.Generic.List <global::Improbable.TestSchema.SomeType>()); } for (var i = 0; i < listSize; i++) { var value = global::Improbable.TestSchema.SomeType.Serialization.Deserialize(obj.IndexObject(4, (uint)i)); update.D.Value.Add(value); } } { var mapSize = obj.GetObjectCount(5); var isCleared = updateObj.IsFieldCleared(5); if (mapSize > 0 || isCleared) { update.E = new global::Improbable.Gdk.Core.Option <global::System.Collections.Generic.Dictionary <global::Improbable.TestSchema.SomeEnum, global::Improbable.TestSchema.SomeType> >(new global::System.Collections.Generic.Dictionary <global::Improbable.TestSchema.SomeEnum, global::Improbable.TestSchema.SomeType>()); } for (var i = 0; i < mapSize; i++) { var mapObj = obj.IndexObject(5, (uint)i); var key = (global::Improbable.TestSchema.SomeEnum)mapObj.GetEnum(1); var value = global::Improbable.TestSchema.SomeType.Serialization.Deserialize(mapObj.GetObject(2)); update.E.Value.Add(key, value); } } return(update); }
public static void SerializeUpdate(global::Improbable.DependentSchema.DependentComponent.Update update, global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj) { var obj = updateObj.GetFields(); { if (update.A.HasValue) { var field = update.A.Value; global::Improbable.TestSchema.ExhaustiveRepeatedData.Serialization.Serialize(field, obj.AddObject(1)); } } { if (update.B.HasValue) { var field = update.B.Value; obj.AddEnum(2, (uint)field); } } { if (update.C.HasValue) { var field = update.C.Value; if (field.HasValue) { obj.AddEnum(3, (uint)field.Value); } if (!field.HasValue) { updateObj.AddClearedField(3); } } } { if (update.D.HasValue) { var field = update.D.Value; foreach (var value in field) { global::Improbable.TestSchema.SomeType.Serialization.Serialize(value, obj.AddObject(4)); } if (field.Count == 0) { updateObj.AddClearedField(4); } } } { if (update.E.HasValue) { var field = update.E.Value; foreach (var keyValuePair in field) { var mapObj = obj.AddObject(5); mapObj.AddEnum(1, (uint)keyValuePair.Key); global::Improbable.TestSchema.SomeType.Serialization.Serialize(keyValuePair.Value, mapObj.AddObject(2)); } if (field.Count == 0) { updateObj.AddClearedField(5); } } } }