示例#1
0
        protected override void ParseDataCollection2Result(DataCollection d, ref object obj)
        {
            var rpd = (ResponseObject)d;
            var responsesobj = rpd.Result;
            var contenttype = rpd.ContentType;

            if (contenttype.ToLower().IndexOf("/xml") > 0)
            {
                if (obj is FrameDLRObject)
                {
                    var dobj = (FrameDLRObject)obj;
                    dobj.Load(responsesobj);
                }
                else if (obj is string)
                {
                    obj = ComFunc.nvl(responsesobj);
                }
            }
            else if (contenttype.ToLower().StartsWith("image")
                || contenttype.ToLower().StartsWith("audio")
                || contenttype.ToLower().StartsWith("video"))
            {
                if (obj is FrameDLRObject)
                {
                    dynamic dobj = (FrameDLRObject)obj;
                    dobj.content = responsesobj;
                    dobj.filename = rpd.FileName;
                    dobj.contenttype = contenttype;
                }
                else if (obj is Stream)
                {
                    if (responsesobj != null)
                        obj = new MemoryStream((byte[])responsesobj);
                }
            }
            else
            {
                if (obj is string)
                {
                    if (responsesobj is byte[])
                    {
                        obj = ComFunc.ByteToString(((byte[])responsesobj), Encoding.UTF8);
                    }
                    else
                    {
                        obj = ComFunc.nvl(responsesobj);
                    }
                }
                else if (obj is FrameDLRObject)
                {
                    var dobj = (FrameDLRObject)obj;
                    if (!(responsesobj is byte[]))
                    {
                        dobj.Load(responsesobj);
                    }
                }
                else
                {
                    FrameDLRObject dobj = FrameDLRObject.CreateInstance(responsesobj);
                    obj = dobj.ToModel(obj.GetType());
                }
            }
        }