Beispiel #1
0
        public static Automap Serdes(Automap map, ISerializer s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            int length;

            byte[] bytes = null;
            if (s.IsReading())
            {
                map ??= new Automap();
                length = (int)s.BytesRemaining;
            }
            else
            {
                if (map == null)
                {
                    throw new ArgumentNullException(nameof(map));
                }
                bytes  = map.AsBytes;
                length = bytes.Length;
            }

            bytes = s.Bytes(null, bytes, length);

            if (s.IsReading())
            {
                map.AsBytes = bytes;
            }

            return(map);
        }
Beispiel #2
0
        public static Automap Serdes(Automap map, ISerializer s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            map ??= new Automap();
            var length = (int)(s.Mode == SerializerMode.Reading ? s.BytesRemaining : map._bytes.Length);

            map._bytes = s.ByteArray(null, map._bytes, length);
            return(map);
        }