예제 #1
0
        public static object FromBytes(byte[] bytes, int type, bool doNotAdapt)
        {
            switch (type)
            {
            case AMF0:
            case AMF3:
                using (MemoryStream stream = new MemoryStream(bytes))
                {
                    using (FlashorbBinaryReader reader = new FlashorbBinaryReader(stream))
                    {
                        IAdaptingType adpatingType = Weborb.Protocols.Amf.RequestParser.readData(reader, type == AMF0 ? 0 : 3);

                        if (doNotAdapt)
                        {
                            return(adpatingType);
                        }
                        else
                        {
                            return(adpatingType.defaultAdapt());
                        }
                    }
                }

            case JSON:
                using (MemoryStream stream = new MemoryStream(bytes))
                {
                    StreamReader streamReader = new StreamReader(stream, Encoding.UTF8);

                    using (JsonTextReader jsonReader = new JsonTextReader(streamReader))
                    {
                        jsonReader.Read();
                        IAdaptingType jsonType = Weborb.Protocols.JsonRPC.RequestParser.Read(jsonReader);

                        if (doNotAdapt)
                        {
                            return(jsonType);
                        }
                        else
                        {
                            return(jsonType.defaultAdapt());
                        }
                    }
                }

#if (!UNIVERSALW8 && !SILVERLIGHT && !PURE_CLIENT_LIB && !WINDOWS_PHONE8)
            case WOLF:

                using (MemoryStream stream = new MemoryStream(bytes))
                {
                    Weborb.Protocols.Wolf.RequestParser parser = Weborb.Protocols.Wolf.RequestParser.GetInstance();
                    Request requestObj = parser.Parse(stream);
                    return(requestObj.getRequestBodyData());
                }
                break;
#endif
            default:
                throw new Exception("Unknown formatting type");
            }
        }
예제 #2
0
        public static object FromBytes(byte[] bytes, int type, bool doNotAdapt)
        {
#if (!UNIVERSALW8 && !SILVERLIGHT && !PURE_CLIENT_LIB && !WINDOWS_PHONE8)
            if (type == AMF0 || type == AMF3)
            {
#endif
            using (MemoryStream stream = new MemoryStream(bytes))
            {
                using (FlashorbBinaryReader reader = new FlashorbBinaryReader(stream))
                {
                    IAdaptingType adpatingType = Weborb.Protocols.Amf.RequestParser.readData(reader, type == AMF0 ? 0 : 3);

                    if (doNotAdapt)
                    {
                        return(adpatingType);
                    }
                    else
                    {
                        return(adpatingType.defaultAdapt());
                    }
                }
            }
#if (!UNIVERSALW8 && !SILVERLIGHT && !PURE_CLIENT_LIB && !WINDOWS_PHONE8)
        }

        else
        {
            using (MemoryStream stream = new MemoryStream(bytes))
            {
                Weborb.Protocols.Wolf.RequestParser parser = Weborb.Protocols.Wolf.RequestParser.GetInstance();
                Request requestObj = parser.Parse(stream);
                return(requestObj.getRequestBodyData());
            }
        }
#endif
        }