コード例 #1
0
        private void RenderMethod(HtmlTextWriter writer, Control container)
        {
            ScriptTemplateControl scriptTemplateControl = ScriptTemplateControl.GetScriptTemplateControl(container);

            // Get the compiled code for the render method logic
            CompiledCode compiledCode = scriptTemplateControl.GetSnippetRenderCode(container.UniqueID, this);

            // Execute it in our module
            EngineHelper.ExecuteCompiledCode(compiledCode, scriptTemplateControl.ScriptModule);

            // We should always find our render function in the module
            // REVIEW: we shouldn't have to do this, and should instead work with a lambda like mechanism (bug 218654)
            object f = scriptTemplateControl.ScriptModule.GetVariable(RenderMethodName);

            Debug.Assert(f != null);

            // Call the render method
            DynamicFunction renderFunction = new DynamicFunction(f);

            EngineHelper.CallMethod(scriptTemplateControl.ScriptEngine, renderFunction, null /*defaultVirtualPath*/,
                                    new SnippetRenderHelper(writer, container.Controls));
        }
コード例 #2
0
 public object CallFunction(DynamicFunction f, params object[] args)
 {
     return(EngineHelper.CallMethod(_scriptEngine, f, _scriptVirtualPath, args));
 }