// /** // * File: RenderContext.cs // * Author: haraldwolff // * // * This file and it's content is copyrighted by the Author and / or copyright holder. // * Any use wihtout proper permission is illegal and may lead to legal actions. // * // * // **/ using System; using System.IO; using System.Collections.Generic; using ln.templates.script; namespace ln.templates.html { public class RenderContext : IScriptContext { public TextWriter ContentWriter { get; } public ITemplateSource TemplateSource { get; set; } Dictionary scriptObjects = new Dictionary(); public IEnumerable ScriptObjectNames => scriptObjects.Keys; public RenderContext(TextWriter contentWriter) { ContentWriter = contentWriter; } public RenderContext(TextWriter contentWriter,ITemplateSource templateSource) :this(contentWriter) { TemplateSource = templateSource; } Dictionary values = new Dictionary(); public object GetScriptObject(string itemName) => scriptObjects[itemName]; public void SetScriptObject(string itemName, object value) => scriptObjects[itemName] = value; } }