Example #1
0
        public override object Decode(byte[] encoded, Type type)
        {
            if (!IsSupportedType(type))
            {
                throw new NotSupportedException(type + " is not supported");
            }

            if ((type == typeof(byte[])) || (type == typeof(object)))
            {
                return(encoded);
            }

            if (type == typeof(string))
            {
                return(DecodeString(encoded));
            }

            if (_intTypeDecoder.IsSupportedType(type))
            {
                return(_intTypeDecoder.Decode(encoded, type));
            }

            if (_boolTypeDecoder.IsSupportedType(type))
            {
                return(_boolTypeDecoder.Decode(encoded, type));
            }

            throw new NotSupportedException();
        }
Example #2
0
 public override bool IsSupportedType(Type type)
 {
     return(type == typeof(byte[]) || type == typeof(string) || intTypeDecoder.IsSupportedType(type) ||
            type == typeof(bool) || type == typeof(object));
 }