// Copyright © 2010-2014 The CefSharp Project. 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 "JavascriptObjectWrapper.h" #include "JavascriptMethodHandler.h" using namespace CefSharp::Internals; using namespace System::Runtime::Serialization; namespace CefSharp { [DataContract] private ref class JavascriptMethodWrapper : public JavascriptMethod, IBindableJavascriptMember { private: MCefRefPtr _javascriptMethodHandler; JavascriptObjectWrapper^ _owner; public: JavascriptMethodWrapper() { _javascriptMethodHandler = new JavascriptMethodHandler(gcnew Func^, Object^>(this, &JavascriptMethodWrapper::Execute)); } virtual void Bind(JavascriptObject^ owner) { _owner = static_cast(owner); auto methodName = StringUtils::ToNative(Description->JavascriptName); auto v8Value = CefV8Value::CreateFunction(methodName, _javascriptMethodHandler.get()); _owner->Value->SetValue(methodName, v8Value, V8_PROPERTY_ATTRIBUTE_NONE); }; void Clone(JavascriptMethod^ obj) { Description = obj->Description; } Object^ Execute(array^ parameters); }; }