protected virtual void SetValue(InternalHandle target, string name, IDictionary dictionary) { var value = this.Engine.CreateObject(); foreach (var key in dictionary.Keys.OfType <string>()) { this.SetValue(value, key, dictionary[key]); } target.SetProperty(name, value); }
internal void OnKeyDown(int keyCode, int charCode) { if (v8.IsDisposed) { return; } using (Handle functHandle = v8.Execute("document.onkeydown", SOURCE_NAME, false)) { if (functHandle.ValueType != JSValueType.CompilerError && functHandle.IsFunction) { InternalHandle obj = v8.CreateObject(); obj.SetProperty("keyCode", keyCode); obj.SetProperty("charCode", charCode); functHandle.AsInternalHandle.StaticCall(obj); } } }
protected virtual void SetValue(InternalHandle target, string name, object value) { if (value is IDictionary dictionary) { this.SetValue(target, name, dictionary); } else { target.SetProperty(name, value); } }
private void MapKeyValues() { Type type = typeof(Key); string[] keyNames = Enum.GetNames(type); Array values = Enum.GetValues(type); InternalHandle key = v8.CreateObject(); for (int i = 0; i < keyNames.Length; i++) { InternalHandle value = v8.CreateValue(values.GetValue(i)); key.SetProperty(keyNames[i], value); } v8.GlobalObject.SetProperty("Key", key); }
internal void OnRenderFrame(RenderingContext rc) { if (v8.IsDisposed) { return; } using (Handle functHandle = v8.Execute("onRenderFrame", SOURCE_NAME, false)) { if (functHandle.ValueType != JSValueType.CompilerError && functHandle.IsFunction) { InternalHandle obj = v8.CreateObject(); obj.SetProperty("time", rc.Time); functHandle.AsInternalHandle.StaticCall(obj); } } }
public V8EngineObject(CefBrowser browser, CefFrame frame, CefV8Context context) { configuration = Extension.GetConfiguration(); try { engine = new V8Engine(); engine.RegisterType(typeof(System.Object), "Object", true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(Type), "Type", true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(String), "String", true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(Boolean), "Boolean", true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(Array), "Array", true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(System.Collections.ArrayList), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(char), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(int), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(Int16), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(Int32), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(Int64), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(UInt16), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(UInt32), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(UInt64), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(Enumerable), null, true, ScriptMemberSecurity.Locked); engine.RegisterType(typeof(File), null, true, ScriptMemberSecurity.Locked); InternalHandle hSystem = engine.CreateObject(); engine.DynamicGlobalObject.System = hSystem; hSystem.SetProperty(typeof(System.Object)); // (Note: No optional parameters used, so this will simply lookup and apply the existing registered type details above.) hSystem.SetProperty(typeof(String)); hSystem.SetProperty(typeof(Boolean)); hSystem.SetProperty(typeof(Array)); engine.GlobalObject.SetProperty(typeof(Type)); engine.GlobalObject.SetProperty(typeof(System.Collections.ArrayList)); engine.GlobalObject.SetProperty(typeof(char)); engine.GlobalObject.SetProperty(typeof(int)); engine.GlobalObject.SetProperty(typeof(Int16)); engine.GlobalObject.SetProperty(typeof(Int32)); engine.GlobalObject.SetProperty(typeof(Int64)); engine.GlobalObject.SetProperty(typeof(UInt16)); engine.GlobalObject.SetProperty(typeof(UInt32)); engine.GlobalObject.SetProperty(typeof(UInt64)); engine.GlobalObject.SetProperty(typeof(Enumerable)); engine.GlobalObject.SetProperty(typeof(Environment)); engine.GlobalObject.SetProperty(typeof(File)); engine.GlobalObject.SetProperty(typeof(Console), V8PropertyAttributes.Locked, null, true, ScriptMemberSecurity.Locked); var db = engine.CreateObject <V8.DatabaseObject>(); var console = engine.CreateObject <V8.ConsoleObject>(); var window = engine.CreateObject <V8.WindowObject>(); var server = engine.CreateObject <V8.ServerObject>(); var xhr = engine.CreateObject <V8.xhrObject>(); //db.AddParent(this.Parent); //console.AddParent(this.Parent); //server.AddParent(this.Parent); window.AddBrowser(browser); engine.DynamicGlobalObject.db = db; engine.DynamicGlobalObject.console = console; engine.DynamicGlobalObject.window = window; engine.DynamicGlobalObject.Server = server; engine.DynamicGlobalObject.jsXHR = xhr; } catch (Exception ex) { Log.Trace(ex.Message, ex.StackTrace, configuration.Verbose); } }