public ShellContext(IServiceProvider serviceProvider, ShellContext parent = null) { ServiceProvider = serviceProvider; _logger = this.GetLogger <ShellContext>(); if (parent == null) { _scope = new VariableScope(null); _dbCache = new Dictionary <string, DatabaseInfo>(); } else { _parent = parent; _dbCache = _parent._dbCache; } }
public ShellContext(ShellContext parent = null) { if (parent == null) { //_engine = Python.CreateEngine(); _engine = GetEngine(); _scope = _engine.CreateScope(); _dbCache = new Dictionary<string, DatabaseInfo>(); } else { _parent = parent; _engine = _parent._engine; _dbCache = _parent._dbCache; OnOutputMessage += ShellContext_OnOutputMessage; } }
public static void ParseRazor(string templateData, Action<string> write, object model, Action<IRazorTemplate, IShellContext> initTemplate = null, IShellContext context = null) { if (!_initialized) { Initialize(); } if (context == null) { context = new ShellContext(null); if (InitializeContext != null) InitializeContext(context); } Action<ITemplate> func = tpl => { var rtpl = (IRazorTemplate) tpl; rtpl.Reset(); rtpl.Context = context; if (initTemplate != null) initTemplate(rtpl, context); if (InitializeTemplate != null) InitializeTemplate(rtpl); }; RazorEngine.Razor.Parse(templateData, write, model, null, func); }
public ShellRunner() { _context = new ShellContext(); _context.OnOutputMessage += _context_OnOutputMessage; }
public ShellRunner(IServiceProvider serviceProvider) { ServiceProvider = serviceProvider; _context = new ShellContext(serviceProvider); }