Make wrapper objects contain references to the Properties/Methods they represent

This commit is contained in:
amaitland
2014-08-28 15:27:06 +10:00
parent d0dc5d9409
commit 0130fa427d
13 changed files with 102 additions and 128 deletions
@@ -7,32 +7,57 @@
#include "Stdafx.h"
#include "include/cef_app.h"
#include "include/cef_base.h"
#include "include/cef_v8.h"
#include "JavascriptMethodWrapper.h"
#include "JavascriptPropertyWrapper.h"
using namespace System::Runtime::Serialization;
using namespace System::Linq;
using namespace System::Collections::Generic;
using namespace CefSharp::Internals;
namespace CefSharp
{
public ref class JavascriptObjectWrapper : public JavascriptObject
public ref class JavascriptObjectWrapper
{
private:
JavascriptObject^ _object;
List<JavascriptMethodWrapper^>^ _wrappedMethods;
List<JavascriptPropertyWrapper^>^ _wrappedProperties;
internal:
MCefRefPtr<CefV8Value> V8Value;
public:
JavascriptObjectWrapper(JavascriptObject^ object)
{
_object = object;
_wrappedMethods = gcnew List<JavascriptMethodWrapper^>();
_wrappedProperties = gcnew List<JavascriptPropertyWrapper^>();
}
void Bind()
{
//TODO: Simplify this
for each (IBindableJavascriptMember^ method in Enumerable::OfType<IBindableJavascriptMember^>(Methods))
for each (JavascriptMethod^ method in Enumerable::OfType<JavascriptMethod^>(_object->Methods))
{
method->Bind(this);
auto wrappedMethod = gcnew JavascriptMethodWrapper(method, _object->Id);
wrappedMethod->V8Value = V8Value;
wrappedMethod->Bind();
_wrappedMethods->Add(wrappedMethod);
}
for each (IBindableJavascriptMember^ prop in Enumerable::OfType<IBindableJavascriptMember^>(Properties))
for each (JavascriptProperty^ prop in Enumerable::OfType<JavascriptProperty^>(_object->Properties))
{
prop->Bind(this);
auto wrappedproperty = gcnew JavascriptPropertyWrapper(prop, _object->Id);
wrappedproperty->V8Value = V8Value;
wrappedproperty->Bind();
_wrappedProperties->Add(wrappedproperty);
}
};
}
};
}