示例#1
0
        public List <PostBody> GetBodys()
        {
            List <PostBody> posts = null;

            if (IsPostMethod())
            {
                IntPtr elementsPtr = BlinkBrowserPInvoke.wkeNetGetPostBody(job);
                if (elementsPtr != IntPtr.Zero)
                {
                    try
                    {
                        wkePostBodyElements elements = (wkePostBodyElements)Marshal.PtrToStructure(elementsPtr, typeof(wkePostBodyElements));
                        if (elements.element != IntPtr.Zero)
                        {
                            posts = new List <PostBody>();
                            for (int i = 0; i < elements.elementSize; i++)
                            {
                                IntPtr             item = Marshal.ReadIntPtr(elements.element, i);
                                wkePostBodyElement e    = (wkePostBodyElement)Marshal.PtrToStructure(item, typeof(wkePostBodyElement));
                                try
                                {
                                    PostBody body = new PostBody();
                                    body.fileLength = e.fileLength;
                                    body.fileStart  = e.fileStart;
                                    body.fileStart  = e.fileStart;
                                    body.filePath   = e.filePath == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(BlinkBrowserPInvoke.wkeGetString(e.filePath));
                                    if (e.data != IntPtr.Zero)
                                    {
                                        wkeMemBuf buf = (wkeMemBuf)Marshal.PtrToStructure(e.data, typeof(wkeMemBuf));
                                        if (buf.data != IntPtr.Zero)
                                        {
                                            body.data = BlinkBrowserPInvoke.IntptrToBytes(buf.data, buf.length);
                                        }
                                    }
                                    posts.Add(body);
                                }
                                finally
                                {
                                    // BlinkBrowserPInvoke.wkeNetFreePostBodyElement(item);
                                }
                            }
                        }
                    }
                    catch
                    {
                        // MessageBox.Show("出错:" + e.Message + "\n" + e.StackTrace);
                    }
                    finally
                    {
                        BlinkBrowserPInvoke.wkeNetFreePostBodyElements(elementsPtr);
                    }
                }
            }
            return(posts);
        }