public SparkTemplate(IFubuFile file, ISparkViewEngine engine) : base(file) { _full = new Lazy <SparkViewDescriptor>(() => createSparkDescriptor(true)); _partial = new Lazy <SparkViewDescriptor>(() => createSparkDescriptor(false)); _viewEntry = new WatchedSparkEntry(() => engine.CreateEntry(_full.Value)); _partialViewEntry = new WatchedSparkEntry(() => engine.CreateEntry(_partial.Value)); }
public SparkTemplate(IFubuApplicationFiles files, IFubuFile file, ISparkViewEngine engine, SparkEngineSettings settings) : base(file, files) { _settings = settings; _full = new Lazy <SparkViewDescriptor>(() => createSparkDescriptor(true)); _partial = new Lazy <SparkViewDescriptor>(() => createSparkDescriptor(false)); _viewEntry = new WatchedSparkEntry(() => engine.CreateEntry(_full.Value)); _partialViewEntry = new WatchedSparkEntry(() => engine.CreateEntry(_partial.Value)); }
public string GetContent(string controllerName, string viewName, string masterName) { var viewDescriptor = GetViewDescriptor(controllerName, viewName, masterName); var viewEntry = _sparkViewEngine.CreateEntry(viewDescriptor); return(viewEntry.SourceCode); }
private string RenderView(SparkViewDescriptor descriptor) { _entry = _engine.CreateEntry(descriptor); var view = _entry.CreateInstance(); var contents = view.RenderView(); _engine.ReleaseInstance(view); return(contents); }
protected virtual ISparkView InstantiateTheView <TViewModel>(SparkViewDescriptor descriptor, TViewModel viewModel) where TViewModel : class { _viewEngine.Settings.PageBaseType = typeof(SparkView <>).MakeGenericType(viewModel.GetType()).ToPrettyString(); ISparkViewEntry entry = _viewEngine.CreateEntry(descriptor); var view = (SparkView <TViewModel>)entry.CreateInstance(); view.ResourcePathManager = _viewEngine.ResourcePathManager; view.Model = viewModel; return(view); }
private ISparkViewEntry getViewEntry(SparkViewDescriptor descriptor) { ISparkViewEntry entry; var key = descriptor.GetHashCode(); _cache.TryGetValue(key, out entry); if (entry == null || !entry.IsCurrent()) { entry = _engine.CreateEntry(descriptor); lock (_cache) { _cache[key] = entry; } } return(entry); }