using System; using System.Linq; using InABox.Core; namespace InABox.Rpc { public class RpcSaveParameters : IRpcCommandParameters { public Type Type { get; set; } public Entity[] Items { get; set; } public string AuditNote { get; set; } public bool ExcludeCustomProperties { get; set; } public string CommandName => "Save"; public RpcSaveParameters() { Items = Array.Empty(); AuditNote = ""; } public void SerializeBinary(CoreBinaryWriter writer) { writer.Write(Type.EntityName()); writer.WriteObjects(Type, Items, (p) => ExcludeCustomProperties ? p is StandardProperty : true); writer.Write(AuditNote); } public void DeserializeBinary(CoreBinaryReader reader) { var type = reader.ReadString(); Type = CoreUtils.GetEntity(type); Items = reader.ReadObjects(Type).ToArray(); AuditNote = reader.ReadString(); } public string FullDescription() => $"Save{Type.Name}({Items.Length}) Data=[{string.Join(", ", Items)}]"; public string ShortDescription() => $"Save{Type.Name}({Items.Length})"; } }