コード例 #1
0
        public object Decode(IChannel channel, MemoryStream input)
        {
            IObjectInput inputo = CodecSupport.GetSerialization(channel.Url, _serializationType)
                                  .Deserialize(input);

            SetAttachment(Constants.DubboVersionKey, inputo.ReadUTF());
            SetAttachment(Constants.PathKey, inputo.ReadUTF());
            SetAttachment(Constants.VersionKey, inputo.ReadUTF());

            MethodName = (inputo.ReadUTF());
            try
            {
                object[] args;
                Type[]   pts;
                string   desc = inputo.ReadUTF();
                if (desc.Length == 0)
                {
                    pts  = DubboCodec.EmptyClassArray;
                    args = DubboCodec.EmptyObjectArray;
                }
                else
                {
                    pts  = ReflectUtil.Desc2ClassArray(desc);
                    args = new object[pts.Length];
                    for (int i = 0; i < args.Length; i++)
                    {
                        try
                        {
                            args[i] = inputo.ReadObject(pts[i]);
                        }
                        catch (Exception)
                        {
                            //
                        }
                    }
                }
                ParameterTypes = (pts);

                Dictionary <string, string> map = inputo.ReadObject <Dictionary <string, string> >();
                if (map != null && map.Count > 0)
                {
                    Dictionary <string, string> attachment = Attachments;
                    if (attachment == null)
                    {
                        attachment = new Dictionary <string, string>();
                    }

                    foreach (var kv in map)
                    {
                        attachment.Add(kv.Key, kv.Value);
                    }

                    Attachments = attachment;
                }
                //decode argument ,may be callback
                for (int i = 0; i < args.Length; i++)
                {
                    args[i] = inputo.ReadObject();
                }

                Arguments = args;
            } catch (Exception e) {
                throw new IOException("Read invocation data failed." + e);
            } finally {
            }
            return(this);
        }