예제 #1
0
        public byte[] EncodeMessage(ISendEntity entity)
        {
            var    entitydata = entity.Serialize();
            var    data       = new byte[entitydata.Length + 7];
            var    converter  = EndianBitConverter.Big;
            ushort bodylen    = (ushort)(entitydata.Length + 2);
            int    offset     = 0;
            ushort flag       = 0x5AA5;
            byte   check      = 0;

            converter.CopyBytes(flag, data, 0);
            offset += 2;
            converter.CopyBytes(entity.CmdID, data, offset);
            offset += 2;
            Buffer.BlockCopy(entitydata, 0, data, offset, (int)entitydata.Length);
            for (int i = 4; i < data.Length - 1; ++i)
            {
                check += data[i];
            }
            data[data.Length - 1] = check;
            return(data);
        }
예제 #2
0
 public void Send(ISendEntity entity)
 {
     Send(_Encoder.EncodeMessage(entity));
 }
예제 #3
0
 public MailJob(ISendEntity <Product> sendProduct)
 {
     this.sendProduct = sendProduct;
 }