Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public string GetContent(string controllerName, string viewName, string masterName)
        {
            var viewDescriptor = GetViewDescriptor(controllerName, viewName, masterName);

            var viewEntry = _sparkViewEngine.CreateEntry(viewDescriptor);

            return(viewEntry.SourceCode);
        }
Ejemplo n.º 4
0
        private string RenderView(SparkViewDescriptor descriptor)
        {
            _entry = _engine.CreateEntry(descriptor);
            var view     = _entry.CreateInstance();
            var contents = view.RenderView();

            _engine.ReleaseInstance(view);
            return(contents);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }