#include "Stdafx.h" #pragma once using namespace System::Collections::Generic; using namespace System::Reflection; namespace CefSharp { namespace Internals { namespace JavascriptBinding { /// /// Acts as an unmanaged wrapper for a managed .NET object. /// private class UnmanagedWrapper : public CefBase { protected: gcroot _obj; gcroot^> _methodMap; gcroot^> _propertyMap; public: gcroot^> Properties; UnmanagedWrapper(Object^ obj) { _obj = obj; _methodMap = gcnew Dictionary(); _propertyMap = gcnew Dictionary(); } /// /// Gets a reference to the wrapped object. /// /// The wrapped object. Object^ Get() { return _obj; } void AddMethodMapping(String^ from, String^ to) { _methodMap->Add(to, from); } String^ GetMethodMapping(String^ from) { String^ value; if (_methodMap->TryGetValue(from, value)) { return value; } else { return nullptr; } } void AddPropertyMapping(String^ from, String^ to) { _propertyMap->Add(to, from); } String^ GetPropertyMapping(String^ from) { String^ value; if (_propertyMap->TryGetValue(from, value)) { return value; } else { return nullptr; } } IMPLEMENT_REFCOUNTING(UnmanagedWrapper); }; } } }