Exemplo n.º 1
0
 public object ReadList(HproseReader reader, int count)
 {
     return(reader.ReadList <T>(count));
 }
Exemplo n.º 2
0
        private object DoInput(object[] arguments, Type returnType, HproseResultMode resultMode, Stream istream)
        {
            int          tag;
            object       result       = null;
            HproseReader hproseReader = new HproseReader(istream, mode);
            MemoryStream memstream    = null;

            if (resultMode == HproseResultMode.RawWithEndTag || resultMode == HproseResultMode.Raw)
            {
                memstream = new MemoryStream();
            }
            while ((tag = hproseReader.CheckTags(
                        (char)HproseTags.TagResult + "" +
                        (char)HproseTags.TagArgument + "" +
                        (char)HproseTags.TagError + "" +
                        (char)HproseTags.TagEnd)) != HproseTags.TagEnd)
            {
                switch (tag)
                {
                case HproseTags.TagResult:
                    if (resultMode == HproseResultMode.Normal)
                    {
                        hproseReader.Reset();
                        result = hproseReader.Unserialize(returnType);
                    }
                    else if (resultMode == HproseResultMode.Serialized)
                    {
                        result = hproseReader.ReadRaw();
                    }
                    else
                    {
                        memstream.WriteByte(HproseTags.TagResult);
                        hproseReader.ReadRaw(memstream);
                    }
                    break;

                case HproseTags.TagArgument:
                    if (resultMode == HproseResultMode.RawWithEndTag || resultMode == HproseResultMode.Raw)
                    {
                        memstream.WriteByte(HproseTags.TagArgument);
                        hproseReader.ReadRaw(memstream);
                    }
                    else
                    {
                        hproseReader.Reset();
                        Object[] args = (Object[])hproseReader.ReadList(HproseHelper.typeofObjectArray);
                        Array.Copy(args, 0, arguments, 0, arguments.Length);
                    }
                    break;

                case HproseTags.TagError:
                    if (resultMode == HproseResultMode.RawWithEndTag || resultMode == HproseResultMode.Raw)
                    {
                        memstream.WriteByte(HproseTags.TagError);
                        hproseReader.ReadRaw(memstream);
                    }
                    else
                    {
                        hproseReader.Reset();
                        result = new HproseException((string)hproseReader.ReadString());
                    }
                    break;
                }
            }
            if (resultMode == HproseResultMode.RawWithEndTag || resultMode == HproseResultMode.Raw)
            {
                if (resultMode == HproseResultMode.RawWithEndTag)
                {
                    memstream.WriteByte(HproseTags.TagEnd);
                }
                memstream.Position = 0;
                result             = memstream;
            }
            return(result);
        }