static JSCompileOptions() { GetElement = getElement; GetElementAttributeName = getElementAttributeName; GetIntroductionScript = getIntroductionScript; DefaultVTable = new VTable { element = Marshal.GetFunctionPointerForDelegate(GetElement), elementAttributeName = Marshal.GetFunctionPointerForDelegate(GetElementAttributeName), introductionScript = Marshal.GetFunctionPointerForDelegate(GetIntroductionScript), }; pDefaultVTable = Marshal.AllocHGlobal(Marshal.SizeOf(DefaultVTable)); Marshal.StructureToPtr(DefaultVTable, pDefaultVTable, false); Default = new JSCompileOptions(); }
private object ExecuteScript(string scriptKey, GetScriptDelegate dlg) { Script scr = _mgr.GetCachedProcessScript(_pd.DefinitionId, scriptKey); if (scr == null) { lock (_mgr) { scr = _mgr.GetCachedProcessScript(_pd.DefinitionId, scriptKey); if (scr == null) { string sc = dlg(); if (sc == null) return null; sc = sc.Trim(); if (!sc.EndsWith(";")) sc += ";"; scr = Script.Compile(sc); _mgr.SetCachedProcessScript(_pd.DefinitionId, scriptKey, scr); } } } scr.Context = GetScriptContext(); return scr.Execute(); }
private object ExecuteScript(string scriptKey, GetScriptDelegate dlg) { log.Debug("Executing script {0}.{1}", _taskDef.ParentProcess.DefinitionId, scriptKey); Script scr = _mgr.GetCachedProcessScript(_taskDef.ParentProcess.DefinitionId, scriptKey); if (scr == null) { lock (_mgr) { scr = _mgr.GetCachedProcessScript(_taskDef.ParentProcess.DefinitionId, scriptKey); if (scr == null) { string sc = dlg(); log.Debug("Script {0}.{1}: compiling script body: {2}", _taskDef.ParentProcess.DefinitionId, scriptKey, sc); if (sc == null) return null; sc = sc.Trim(); if (!sc.EndsWith(";")) sc += ";"; scr = Script.Compile(sc); _mgr.SetCachedProcessScript(_taskDef.ParentProcess.DefinitionId, scriptKey, scr); } } } scr.Context = GetScriptContext(); return scr.Execute(); }