예제 #1
0
 public byte[] SerializeCommand(Common.ISerializable data)
 {
     if (data == null)
     {
         return(new byte[0]);
     }
     using (var mem = new MemoryStream())
     {
         SerializeCommand(data, mem);
         mem.Flush();
         return(mem.ToArray());
     }
 }
예제 #2
0
        public void SerializeCommand(Common.ISerializable data, Stream stream)
        {
            var type = data.GetType();

            if (type == typeof(t_NullCmd))
            {
                new CommandTag().Serialize(stream);
                new t_NullCmd().Serialize(stream);
                return;
            }
            var tag = this[type];

            if (tag == null)
            {
                throw new KeyNotFoundException(type.FullName);
            }
            tag.Serialize(stream);
            data.Serialize(stream);
        }