public void AfterFirstRun(Evaluator evaluator) { this.Evaluator = evaluator; OnAfterFirstRun(); }
public void Write(TextWriter textWriter, PageContext pageContext) { if (textWriter == null) { throw new ArgumentNullException("textWriter"); } if (pageContext == null) { pageContext = new PageContext(this, new Dictionary <string, object>(), true); } var blocks = pageContext.RenderHtml ? this.HtmlBlocks : this.MarkdownBlocks; if (Interlocked.Increment(ref timesRun) == 1) { lock (readWriteLock) { try { isBusy = true; this.ExecutionContext.BaseType = Markdown.MarkdownBaseType; this.ExecutionContext.TypeProperties = Markdown.MarkdownGlobalHelpers; pageContext.MarkdownPage = this; var initHtmlContext = pageContext.Create(this, true); var initMarkdownContext = pageContext.Create(this, false); foreach (var block in this.HtmlBlocks) { block.DoFirstRun(initHtmlContext); } foreach (var block in this.MarkdownBlocks) { block.DoFirstRun(initMarkdownContext); } this.evaluator = this.ExecutionContext.Build(); foreach (var block in this.HtmlBlocks) { block.AfterFirstRun(evaluator); } foreach (var block in this.MarkdownBlocks) { block.AfterFirstRun(evaluator); } AddDependentPages(blocks); initException = null; hasCompletedFirstRun = true; } catch (Exception ex) { initException = ex; throw; } finally { isBusy = false; } } } lock (readWriteLock) { while (isBusy) { Monitor.Wait(readWriteLock); } } if (initException != null) { timesRun = 0; throw initException; } MarkdownViewBase instance = null; if (this.evaluator != null) { instance = (MarkdownViewBase)this.evaluator.CreateInstance(); object model; pageContext.ScopeArgs.TryGetValue(ModelName, out model); instance.Init(Markdown.AppHost, this, pageContext.ScopeArgs, model, pageContext.RenderHtml); } foreach (var block in blocks) { block.Write(instance, textWriter, pageContext.ScopeArgs); } if (instance != null) { instance.OnLoad(); } }
public T Evaluate <T>(Dictionary <string, object> scopeArgs, bool defaultToNullValues) { var paramValues = GetParamValues(scopeArgs, defaultToNullValues); return((T)Evaluator.Evaluate(CodeGenMethodName, paramValues.ToArray())); }