Пример #1
0
        public static void RegisterViewEngine(ViewEngineCollection engines)
        {
            var sparkSettings = new SparkSettings();

            sparkSettings
                .AddNamespace("System")
                .AddNamespace("System.Collections.Generic")
                .AddNamespace("System.Linq")
                .AddNamespace("System.Web.Mvc")
                .AddNamespace("System.Web.Mvc.Html");

            sparkSettings
                .AddAssembly("Spark.Web.Mvc")
                .AddAssembly("System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35")
                .AddAssembly("System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");

            var builder = new DefaultDescriptorBuilder();
            builder.Filters.Add(new AreaDescriptorFilter());

            var container = SparkEngineStarter.CreateContainer(sparkSettings);
            container.SetServiceBuilder<Spark.Web.Mvc.IDescriptorBuilder>(c => builder);
            SparkEngineStarter.RegisterViewEngine(container);

            engines.Add(new SparkViewFactory(sparkSettings));
        }
Пример #2
0
        public SparkViewFactory Configure()
        {
            var assemblyWithViews = Assembly.GetAssembly(typeof(HomeController));

            var settings = new SparkSettings()
                .AddAssembly(assemblyWithViews)
                .AddViewFolder(typeof(VirtualFileSystemViewFolder), new Dictionary<string, string>
                                                              {
                                                                  {"basePath", FilePaths.ViewsFolder.Replace("\\Views", string.Empty)}
                                                              })
                .AddViewFolder(ViewFolderType.FileSystem, new Dictionary<string, string>
                                                              {
                                                                  {"basePath", FilePaths.ViewsFolder}
                                                              })
                .AddViewFolder(ViewFolderType.FileSystem, new Dictionary<string, string>
                                                              {
                                                                  {"basePath", FilePaths.ThemesFolder}
                                                              })
                .SetAutomaticEncoding(true);

            foreach (var assemblyName in assemblyWithViews.GetReferencedAssemblies())
            {
                settings.AddAssembly(assemblyName.FullName);
            }

            return new SparkViewFactory(settings);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SparkEngine"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException"><c>viewBaseType</c> or <c>handler</c> is <c>null</c>.</exception>
        public SparkEngine(Type viewBaseType, InitializeViewHandler handler)
        {
            if (viewBaseType == null) throw new ArgumentNullException("viewBaseType");
            if (handler == null) throw new ArgumentNullException("handler");
            _viewBaseType = viewBaseType;
            _handler = handler;
            _currentEngine = this;

            SparkSettings settings = new SparkSettings();
            settings.AddNamespace("System.Collections.Generic");
            settings.AddNamespace("HttpServer.Mvc.Views");
            settings.AddNamespace("HttpServer.ViewEngine.Spark");
            settings.AddAssembly(GetType().Assembly);
            settings.AddAssembly(typeof (Server).Assembly);
            _engine = new SparkViewEngine(settings)
            {
                ViewFolder = new MyViewFolder(),
                DefaultPageBaseType = viewBaseType.FullName
            };
        }
Пример #4
0
        private static void ConfigureViewImports(SparkSettings settings)
        {
            settings.AddAssembly("Spark.Web.Mvc")
                    .AddAssembly("System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
                    .AddAssembly("System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
                    .AddAssembly("System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");

            settings.AddNamespace("System")
                    .AddNamespace("System.Collections.Generic")
                    .AddNamespace("System.Linq")
                    .AddNamespace("System.Web.Mvc")
                    .AddNamespace("System.Web.Mvc.Html")
                    .AddNamespace("System.Web.Optimization");
        }
        private static ISparkSettings GetSparkSettings(Assembly callingAssembly)
        {
            var sparkSettings = new SparkSettings();

            sparkSettings.AddAssembly(callingAssembly);

            #if DEBUG
            sparkSettings.SetDebug(true);
            #endif

            sparkSettings.SetAutomaticEncoding(false);
            sparkSettings.NullBehaviour = NullBehaviour.Strict;

            return sparkSettings;
        }
Пример #6
0
        public static void Configure(ViewEngineCollection engines)
        {
            //engines.Clear();
            var settings = new SparkSettings
                               {
                                   AutomaticEncoding = true,
                                   Debug = true,
                               };

            settings
                .AddAssembly(typeof(LearningTrackerMvcApplication).Assembly.GetName().Name)
                .AddAssembly(typeof(Controller).Assembly.GetName().Name)
                .SetPageBaseType("ApplicationViewPage");
            var viewFactory = new SparkViewFactory(settings);
            PrecompileViews(viewFactory);
            engines.Add(viewFactory);
        }
Пример #7
0
        public void Configure()
        {
            _engines.Clear();
            var settings = new SparkSettings
                               {
                                   AutomaticEncoding = true,
                                   Debug = true,
                               };

            settings
                .AddAssembly(typeof(IConfigurator).Assembly)
                .AddAssembly(typeof(Controller).Assembly)
                .SetPageBaseType("ApplicationView");
            var viewFactory = new SparkViewFactory(settings);
            //PrecompileViews(viewFactory);
            _engines.Add(viewFactory);
        }