mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 03:32:37 +00:00
8a367fbdc4
* Net Core - Rename CefSharp.Core.dll to CefSharp.Core.Runtime.dll Partial rename, only Net Core, folder not renamed * Net Core - Rename CefSharp.Core.RefAssembly to CefSharp.Core.netcore Remove GenApi * Core - Rename CefDragDataWrapper to DragData Move into CefSharp.Core namespace * WinForms/WPF/OffScreen - Migrate from GitLink command line to Nuget package * Net Core - Refactor to have CefSharp.Core.dll contain only public Api * Net Core - Remove CefSharp.Core.RefAssembly * Net Core - Change CefSharp.Core.netcore output folder * Net Core - Restructure nuget packages * Net Core - Add Cefsharp.Core.Runtime.RefAssembly * Net Core - Hide CLI/C++ classes from intellisense Make sure users don't attempt to load them directly * Rename CefSharp.Core to CefSharp.Core.Runtime * Core - Restructure Net 4.5.2 packages to use CefSharp.Core.dll anycpu variant Attempt to load CefSharp.Core.Runtime at runtime rather than having to use msbuild to copy the correct version * Rename CefSharp.Core.netcore to CefSharp.Core * WPF/WinForms/OffScreen - Change from x86/64 to AnyCPU As they are all managed assemblies they can target AnyCPU. Includes CefSharp.dll * Convert RequestContextBuilder from C++ to C# Now part of the CefSharp.Core PublicApi * Update version number to 87.1.11 * Migrate more of the public Api to C# * Net Core - Basic restructure complete * Net Core - ModuleInitializer (Doesn't work yet) * Remove direct references to BrowserSettings * Net Core - ModuleInitializer load CefShar.Core.Runtime.dl * Net Core - Load libcef.dll via CLR Module initializer If no RID is specified then we can load libcef.dll using the module initializer * Add version to CefSharp.Core * Remove dependency on CefSharp.Core.Runtime Rewrite common targets * AnyCPU app.config transform Improve AnyCPU support * Improve Net Core 3 support Only delete CefSharp.Core.Runtime.dll when AnyCPU * Nuget - Add CefSharp.Core.Runtime reference when TargetFramework = NetCore * Fix Typos Based on #3306 * Net Core - Rename CefSharp.Core.Runtime RefAssembly source file * Net Full - Generate CefSharp.Core.Runtime Ref Assembly For now the powershell build script generates the .cs file based on a x86 release build.ps1 It's not possible to directly install GenApi as it requires a Sdk style project * Net Core - Old packages copy files to required folders * Test - Install newer .Net Compiler and set Lang Version to 7.3 * Net Core - Exclude Net 452 Runtime generated reference source * Core - Add Refactoring TODO * Ref Assembly - Generate source as part of build - Move ref assembly source generate into GenerateRefAssemblySource.ps1 - Call before project build Runs locally, see if Appveyor has a problem with the powershell script execution * Core - Add more factory methods to create instances of managed wrappers * Net Core - Make Initialzier properties internal Not quite sure what the public API should look like as yet, so making internal for now.
239 lines
7.2 KiB
C++
239 lines
7.2 KiB
C++
// 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 "PostDataElement.h"
|
|
#include "Internals\TypeConversion.h"
|
|
#include "Internals\CefWrapper.h"
|
|
|
|
using namespace System::Collections::Generic;
|
|
using namespace System::Collections::ObjectModel;
|
|
|
|
namespace CefSharp
|
|
{
|
|
namespace Core
|
|
{
|
|
/// <summary>
|
|
/// Form Post Data
|
|
/// </summary>
|
|
/// <seealso cref="T:IPostData"/>
|
|
[System::ComponentModel::EditorBrowsableAttribute(System::ComponentModel::EditorBrowsableState::Never)]
|
|
public ref class PostData : public IPostData, public CefWrapper
|
|
{
|
|
MCefRefPtr<CefPostData> _postData;
|
|
List<IPostDataElement^>^ _postDataElements;
|
|
|
|
internal:
|
|
PostData(CefRefPtr<CefPostData> &postData) :
|
|
_postData(postData)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finalizer.
|
|
/// </summary>
|
|
!PostData()
|
|
{
|
|
_postData = nullptr;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Destructor.
|
|
/// </summary>
|
|
~PostData()
|
|
{
|
|
this->!PostData();
|
|
|
|
if (_postDataElements != nullptr)
|
|
{
|
|
//Make sure the unmanaged resources are handled
|
|
for each (IPostDataElement^ element in _postDataElements)
|
|
{
|
|
delete element;
|
|
}
|
|
|
|
_postDataElements = nullptr;
|
|
}
|
|
|
|
_disposed = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Throw exception if Readonly
|
|
/// </summary>
|
|
/// <exception cref="Exception">Thrown when an exception error condition occurs.</exception>
|
|
void ThrowIfReadOnly()
|
|
{
|
|
if (IsReadOnly)
|
|
{
|
|
throw gcnew Exception(gcnew String(L"This IPostDataWrapper is readonly and cannot be modified."));
|
|
}
|
|
}
|
|
|
|
operator CefRefPtr<CefPostData>()
|
|
{
|
|
if (this == nullptr)
|
|
{
|
|
return NULL;
|
|
}
|
|
return _postData.get();
|
|
}
|
|
|
|
public:
|
|
/// <summary>
|
|
/// Default constructor.
|
|
/// </summary>
|
|
PostData()
|
|
{
|
|
_postData = CefPostData::Create();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns true if this object is read-only.
|
|
/// </summary>
|
|
virtual property bool IsReadOnly
|
|
{
|
|
bool get()
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
return _postData->IsReadOnly();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve the post data elements.
|
|
/// </summary>
|
|
virtual property IList<IPostDataElement^>^ Elements
|
|
{
|
|
IList<IPostDataElement^>^ get()
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
if (_postDataElements == nullptr)
|
|
{
|
|
_postDataElements = gcnew List<IPostDataElement^>();
|
|
|
|
auto elementCount = _postData.get() ? _postData->GetElementCount() : 0;
|
|
if (elementCount == 0)
|
|
{
|
|
return gcnew ReadOnlyCollection<IPostDataElement^>(_postDataElements);
|
|
}
|
|
CefPostData::ElementVector ev;
|
|
|
|
_postData->GetElements(ev);
|
|
|
|
for (CefPostData::ElementVector::iterator it = ev.begin(); it != ev.end(); ++it)
|
|
{
|
|
CefPostDataElement *el = it->get();
|
|
|
|
_postDataElements->Add(gcnew PostDataElement(el));
|
|
}
|
|
}
|
|
|
|
return gcnew ReadOnlyCollection<IPostDataElement^>(_postDataElements);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add the specified <see cref="IPostDataElement"/>.
|
|
/// </summary>
|
|
/// <param name="element">element to be added.</param>
|
|
/// <returns>Returns true if the add succeeds.</returns>
|
|
virtual bool AddElement(IPostDataElement^ element)
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
ThrowIfReadOnly();
|
|
|
|
//Access the Elements collection to initialize the underlying _postDataElements collection
|
|
auto elements = Elements;
|
|
|
|
//If the element has already been added then don't add it again
|
|
if (elements->Contains(element))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
_postDataElements->Add(element);
|
|
|
|
auto elementWrapper = (PostDataElement^)element;
|
|
|
|
return _postData->AddElement(elementWrapper);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove the specified <see cref="IPostDataElement"/>.
|
|
/// </summary>
|
|
/// <param name="element">element to be removed.</param>
|
|
/// <returns> Returns true if the add succeeds.</returns>
|
|
virtual bool RemoveElement(IPostDataElement^ element)
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
ThrowIfReadOnly();
|
|
|
|
//Access the Elements collection to initialize the underlying _postDataElements collection
|
|
auto elements = Elements;
|
|
|
|
if (!elements->Contains(element))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
_postDataElements->Remove(element);
|
|
|
|
auto elementWrapper = (PostDataElement^)element;
|
|
|
|
return _postData->RemoveElement(elementWrapper);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove all existing post data elements.
|
|
/// </summary>
|
|
virtual void RemoveElements()
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
ThrowIfReadOnly();
|
|
|
|
_postData->RemoveElements();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a new <see cref="IPostDataElement"/> instance
|
|
/// </summary>
|
|
/// <returns>PostDataElement</returns>
|
|
virtual IPostDataElement^ CreatePostDataElement()
|
|
{
|
|
auto element = CefPostDataElement::Create();
|
|
|
|
return gcnew PostDataElement(element);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns true if the underlying POST data includes elements that are not
|
|
/// represented by this IPostData object (for example, multi-part file upload
|
|
/// data). Modifying IPostData objects with excluded elements may result in
|
|
/// the request failing.
|
|
/// </summary>
|
|
virtual property bool HasExcludedElements
|
|
{
|
|
bool get()
|
|
{
|
|
ThrowIfDisposed();
|
|
|
|
return _postData->HasExcludedElements();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|