private static object _DecodeVal(byte[] buff, ref int _readHead) { byte type = buff[_readHead++]; AMFTypes amfType = (AMFTypes)Enum.ToObject(typeof(AMFTypes), (int)type); switch (amfType) { case AMFTypes.String: return(_DecodeKey(buff, ref _readHead)); case AMFTypes.Number: byte[] flip = new byte[sizeof(double)]; Buffer.BlockCopy(buff, _readHead, flip, 0, flip.Length); double num = BitConverter.ToDouble(flip.ToBE(), 0); _readHead += sizeof(double); return(num); case AMFTypes.Boolean: byte b = buff[_readHead++]; return(b); case AMFTypes.End: return(null); default: throw new MissingMethodException(); } }
private object DecodeVal(byte[] buff) { byte type = buff[_readHead++]; AMFTypes amfType = (AMFTypes)Enum.ToObject(typeof(AMFTypes), (int)type); switch (amfType) { case AMFTypes.String: // read string size.. return(DecodeKey(buff)); case AMFTypes.Number: byte[] flip = new byte[sizeof(double)]; Buffer.BlockCopy(buff, _readHead, flip, 0, flip.Length); double num = BitConverter.ToDouble(flip.Reverse().ToArray(), 0); _readHead += sizeof(double); return(num); case AMFTypes.Boolean: byte b = buff[_readHead++]; return(b); case AMFTypes.End: return(null); default: // could make this a real Amf Enc/Dec but it is not required for my needs.. throw new MissingMethodException(); } }