private static T Decode <T>(DeTeWeType type, string hex) where T : DeTeWeElement
        {
            var data    = HexEncoding.HexToByte(hex.Replace(" ", String.Empty));
            var element = DeTeWeElement.Create(type, data);

            return(Assert.IsType <T>(element));
        }
Example #2
0
        public static DeTeWeElement Create(DeTeWeType type, ReadOnlyMemory <byte> data)
        {
            try
            {
                switch (type)
                {
                case DeTeWeType.BtEthAddr:
                    return(new BtEthAddrDeTeWeElement(data));

                case DeTeWeType.DateTime:
                    return(new DateTimeDeTeWeElement(data));

                case DeTeWeType.Display:
                    return(new DisplayDeTeWeElement(data));

                case DeTeWeType.Display2:
                    return(new Display2DeTeWeElement(data));

                case DeTeWeType.HomeScreenText:
                    return(new HomeScreenTextDeTeWeElement(data));

                case DeTeWeType.Language:
                    return(new LanguageDeTeWeElement(data));

                case DeTeWeType.Reserved2:
                    return(new Reserved2DeTeWeElement(data));

                case DeTeWeType.SendText:
                    return(new SendTextDeTeWeElement(data));

                case DeTeWeType.Reserved1:
                    return(new Reserved1DeTeWeElement(data));

                default:
                    return(new UnknownDeTeWeElement(type, data));
                }
            }
            catch
            {
                return(new UnknownDeTeWeElement(type, data));
            }
        }
 public UnknownDeTeWeElement(DeTeWeType type, ReadOnlyMemory <byte> data) : base(type, data)
 {
 }
Example #4
0
 protected DeTeWeElement(DeTeWeType type, ReadOnlyMemory <byte> data)
 {
     Type = type;
     Raw  = data;
 }