Exemple #1
0
        public override byte[] Serialize()
        {
            List <byte> s = new List <byte>();

            // serialize FirstName
            s.Add((byte)((FirstName == null) ? 0 : 1));
            if (FirstName != null)
            {
                List <byte> tmp0 = new List <byte>();
                tmp0.AddRange(BitConverter.GetBytes((uint)FirstName.Count()));
                while (tmp0.Count > 0 && tmp0.Last() == 0)
                {
                    tmp0.RemoveAt(tmp0.Count - 1);
                }
                s.Add((byte)tmp0.Count);
                s.AddRange(tmp0);

                s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(FirstName));
            }

            // serialize _LastName_
            s.Add((byte)((_LastName_ == null) ? 0 : 1));
            if (_LastName_ != null)
            {
                List <byte> tmp1 = new List <byte>();
                tmp1.AddRange(BitConverter.GetBytes((uint)_LastName_.Count()));
                while (tmp1.Count > 0 && tmp1.Last() == 0)
                {
                    tmp1.RemoveAt(tmp1.Count - 1);
                }
                s.Add((byte)tmp1.Count);
                s.AddRange(tmp1);

                s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(_LastName_));
            }

            return(s.ToArray());
        }