RpcSaveParameters.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Linq;
  3. using InABox.Core;
  4. namespace InABox.Rpc
  5. {
  6. public class RpcSaveParameters : IRpcCommandParameters
  7. {
  8. public Type Type { get; set; }
  9. public Entity[] Items { get; set; }
  10. public string AuditNote { get; set; }
  11. public bool ExcludeCustomProperties { get; set; }
  12. public string CommandName => "Save";
  13. public RpcSaveParameters()
  14. {
  15. Items = Array.Empty<Entity>();
  16. AuditNote = "";
  17. }
  18. public void SerializeBinary(CoreBinaryWriter writer)
  19. {
  20. writer.Write(Type.EntityName());
  21. writer.WriteObjects(Type, Items, (p) => ExcludeCustomProperties ? p is StandardProperty : true);
  22. writer.Write(AuditNote);
  23. }
  24. public void DeserializeBinary(CoreBinaryReader reader)
  25. {
  26. var type = reader.ReadString();
  27. Type = CoreUtils.GetEntity(type);
  28. Items = reader.ReadObjects<Entity>(Type).ToArray();
  29. AuditNote = reader.ReadString();
  30. }
  31. public string FullDescription() => $"Save{Type.Name}({Items.Length}) Data=[{string.Join<Entity>(", ", Items)}]";
  32. public string ShortDescription() => $"Save{Type.Name}({Items.Length})";
  33. }
  34. }