admin
2020-06-10 a610f2ab6e543d2cb78c1ef212ac6a74ddc067d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright © 2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
 
#pragma once
 
#include "Stdafx.h"
 
#include "include\cef_request.h"
#include "Internals\TypeConversion.h"
#include "Internals\CefWrapper.h"
 
using namespace System::Collections::Specialized;
 
namespace CefSharp
{
    public ref class PostDataElement : public IPostDataElement, public CefWrapper
    {
        MCefRefPtr<CefPostDataElement> _postDataElement;
    internal:
        PostDataElement(CefRefPtr<CefPostDataElement> postDataElement) :
            _postDataElement(postDataElement)
        {
 
        }
 
        !PostDataElement()
        {
            _postDataElement = nullptr;
        }
 
        ~PostDataElement()
        {
            this->!PostDataElement();
 
            _disposed = true;
        }
 
    public:
        PostDataElement()
        {
            _postDataElement = CefPostDataElement::Create();
        }
 
        virtual property bool IsReadOnly
        {
            bool get()
            {
                ThrowIfDisposed();
 
                return _postDataElement->IsReadOnly();
            }
        }
 
        virtual property String^ File
        {
            String^ get()
            {
                ThrowIfDisposed();
 
                return StringUtils::ToClr(_postDataElement->GetFile());
            }
            void set(String^ val)
            {
                ThrowIfDisposed();
 
                _postDataElement->SetToFile(StringUtils::ToNative(val));
            }
        }
 
        virtual void SetToEmpty()
        {
            ThrowIfDisposed();
 
            _postDataElement->SetToEmpty();
        }
 
        virtual property PostDataElementType Type
        {
            PostDataElementType get()
            {
                ThrowIfDisposed();
 
                return (PostDataElementType)_postDataElement->GetType();
            }
        }
 
        virtual property cli::array<Byte>^ Bytes
        {
            cli::array<Byte>^ get()
            {
                ThrowIfDisposed();
 
                auto byteCount = _postDataElement->GetBytesCount();
                if (byteCount == 0)
                {
                    return nullptr;
                }
 
                auto bytes = gcnew cli::array<Byte>(byteCount);
                pin_ptr<Byte> src = &bytes[0]; // pin pointer to first element in arr
 
                _postDataElement->GetBytes(byteCount, static_cast<void*>(src));
 
                return bytes;
            }
            void set(cli::array<Byte>^ val)
            {
                ThrowIfDisposed();
 
                pin_ptr<Byte> src = &val[0];
                _postDataElement->SetToBytes(val->Length, static_cast<void*>(src));
            }
        }
 
        operator CefRefPtr<CefPostDataElement>()
        {
            if (this == nullptr)
            {
                return NULL;
            }
            return _postDataElement.get();
        }
    };
}