Ejemplo n.º 1
0
        public static SparkSettings CreateSparkSettings()
        {
            var settings = new SparkSettings();

            settings.Debug = true;

            settings.AddAssembly("Newtonsoft.Json");
            settings.AddAssembly("RedBranch.Hammock");
            settings.AddAssembly("Ascend.Core");
            settings.AddAssembly("Ascend.Infrastructure");
            settings.AddAssembly("Ascend.Web.Admin");

            settings.AddNamespace("System");
            settings.AddNamespace("System.Collections.Generic");
            settings.AddNamespace("System.Linq");
            settings.AddNamespace("System.Web");
            settings.AddNamespace("System.Web.Routing");
            settings.AddNamespace("System.Web.Mvc");
            settings.AddNamespace("System.Web.Mvc.Html");
            settings.AddNamespace("Newtonsoft.Json");
            settings.AddNamespace("RedBranch.Hammock");
            settings.AddNamespace("Ascend.Core");
            settings.AddNamespace("Ascend.Core.Repositories");
            settings.AddNamespace("Ascend.Core.Services");
            settings.AddNamespace("Ascend.Infrastructure");
            settings.AddNamespace("Ascend.Infrastructure.Web");
            settings.AddNamespace("Ascend.Web.Admin");
            return(settings);
        }
Ejemplo n.º 2
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
            };
        }
Ejemplo n.º 3
0
        public SparkViewEngine Engine()
        {
            if (engine != null)
            {
                return(engine);
            }

            var settings = new SparkSettings()
                           .SetPageBaseType(typeof(WebFormsSparkView))
                           .SetNullBehaviour(NullBehaviour.Strict);

            foreach (var ns in namespaces)
            {
                settings = settings.AddNamespace(ns);
            }
            foreach (var a in assemblies)
            {
                settings = settings.AddAssembly(a);
            }

            engine = new SparkViewEngine(settings);

            engine.ViewFolder = GetViewFolder();

            engine.BatchCompilation(GetViewDescriptors());
            return(engine);
        }
Ejemplo n.º 4
0
        public void SettingsAreMergedRightToLeft()
        {
            var left = new SparkSettings();
            var right = new SparkSettings();

            right.NullBehaviour = NullBehaviour.Strict;
            right.PageBaseType = "test";
            right.Prefix = "test";
            right.StatementMarker = "T";
            right.AutomaticEncoding = true;
            right.AddResourceMapping("test", "test");
            right.AddAssembly("test");
            right.AddNamespace("test");
            right.AddViewFolder(typeof (int), new Dictionary<string, string>());

            Merger.Merge(left, right);

            left.NullBehaviour.ShouldEqual(right.NullBehaviour);
            left.NullBehaviour.ShouldEqual(right.PageBaseType);
            left.NullBehaviour.ShouldEqual(right.Prefix);
            left.NullBehaviour.ShouldEqual(right.StatementMarker);
            left.NullBehaviour.ShouldEqual(right.AutomaticEncoding);
            left.ResourceMappings.ShouldEqual(right.ResourceMappings);
            left.UseAssemblies.ShouldEqual(right.UseAssemblies);
            left.UseNamespaces.ShouldEqual(right.UseNamespaces);
        }
        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);
        }
Ejemplo n.º 6
0
        private void configureNamespaces(BehaviorGraph graph)
        {
            _sparkSettings.SetAutomaticEncoding(true);

            _sparkSettings.AddAssembly(typeof(HtmlTag).Assembly)
            .AddAssembly(typeof(IPartialInvoker).Assembly)
            .AddNamespace(typeof(IPartialInvoker).Namespace)
            .AddNamespace(typeof(VirtualPathUtility).Namespace) // System.Web
            .AddNamespace(typeof(SparkViewFacility).Namespace)  // FubuMVC.Spark
            .AddNamespace(typeof(HtmlTag).Namespace);           // HtmlTags

            var engineSettings = graph.Settings.Get <SparkEngineSettings>();

            engineSettings.UseNamespaces.Each(ns => _sparkSettings.AddNamespace(ns));
        }
 public ConfigureSparkSettingsExpression AddAssembly(Assembly assembly)
 {
     _settings.AddAssembly(assembly);
     return(this);
 }