Example #1
0
        public MvcToFubuRegistry(SparkViewFactory factory)
            : base(factory)
        {
            _factory = factory;

            Applies.ToThisAssembly();

            IncludeDiagnostics(true);

            Actions
                .IncludeTypesNamed(x => x.EndsWith("Controller"));

            SparkPolicies
                .AttachViewsBy(call =>
                               call.HandlerType.Name.EndsWith("Controller"),
                               call => call.HandlerType.Name.RemoveSuffix("Controller"),
                               call => call.Method.Name);
            Routes
                .IgnoreMethodsNamed("Index")
                .IgnoreNamespaceText("MvcToFubu.Content.Controllers")
                .ForInputTypesOf<IIdentifiableName>(c => c.RouteInputFor(i => i.Name));

            HtmlConvention<DefaultHtmlConventions>();

            HomeIs<HomeController>(c => c.Home());
        }
Example #2
0
        public MigrationSampleRegistry(bool debuggingEnabled, string controllerAssembly, SparkViewFactory viewFactory)
            : base(debuggingEnabled, controllerAssembly)
        {
            _viewFactory = viewFactory;

            //HomeIs<HomeController>(c => c.List(new ListInputModel() { Page = 1 }));

            Output.To(call => new JavaScriptOutputNode(GetJavaScriptViewToken(call), call))
                .WhenTheOutputModelIs<JavaScriptResponse>();
        }
Example #3
0
        public SparkFubuRegistry(SparkViewFactory factory)
        {
            Factory = factory;

            var resolver = new SparkPolicyResolver(_sparkPolicies);

            Views
                .Facility(new SparkViewFacility(Factory, resolver))
                .TryToAttach(x => x.by(new ActionAndViewMatchedBySparkViewDescriptors(resolver)));
        }
Example #4
0
        public HelloSparkRegistry(bool enableDiagnostics, string controllerAssembly, SparkViewFactory sparkViewFactory)
            : base(enableDiagnostics, controllerAssembly)
        {
            _sparkViewFactory = sparkViewFactory;

            Output.ToJson.WhenTheOutputModelIs<JsonResponse>();

            Output.To(call => new JavaScriptOutputNode(GetJavaScriptViewToken(call), call))
                .WhenTheOutputModelIs<JavaScriptResponse>();

            HomeIs<AirController>(c => c.TakeABreath());
        }
Example #5
0
        public HelloSparkRegistry(bool enableDiagnostics, string controllerAssembly, SparkViewFactory sparkViewFactory)
            : base(enableDiagnostics, controllerAssembly)
        {
            _sparkViewFactory = sparkViewFactory;

            AddViewFolder("/Features/");

            Actions.IncludeTypesNamed(x => x.EndsWith("Controller"));
            AttachViewsBy(
                actionType => actionType.Name.EndsWith("Controller"),
                action => action.RemoveSuffix("Controller"));

            Output.ToJson.WhenTheOutputModelIs<JsonResponse>();
            Output.To(call => new JavaScriptOutputNode(GetJavaScriptViewToken(call), call))
                .WhenTheOutputModelIs<JavaScriptResponse>();

            HomeIs<AirController>(c => c.TakeABreath());
        }
Example #6
0
        public static FubuRegistry Spark(this FubuRegistry registry, Action <ConfigureSparkExpression> configure)
        {
            var settings = new SparkSettings()
                           .AddAssembly(typeof(HtmlTag).Assembly)
                           .AddAssembly(typeof(FubuPageExtensions).Assembly)
                           .AddNamespace(typeof(FubuRegistryExtensions).Namespace) // Spark.Web.FubuMVC
                           .AddNamespace(typeof(FubuPageExtensions).Namespace)     // FubuMVC.Core.UI
                           .AddNamespace(typeof(HtmlTag).Namespace);               // HtmlTags

            var policies = new List <ISparkPolicy>();
            var visitors = new List <ISparkDescriptorVisitor>();

            var expression = new ConfigureSparkExpression(settings, policies, visitors);

            // TODO -- this shouldn't be assuming the location of the package folder.
            // go through the front end and get this out of the package
            PackageRegistry.Packages.Each(package => registerViewFolder(expression, package));

            configure(expression);

            var factory         = new SparkViewFactory(settings);
            var resolver        = new SparkPolicyResolver(policies);
            var visitorRegistry = new SparkDescriptorVisitorRegistry(visitors);

            registry
            .Services(c =>
            {
                c.SetServiceIfNone <ISparkViewFactory>(factory);
                c.SetServiceIfNone(factory.Settings);
                c.SetServiceIfNone(typeof(ISparkViewRenderer <>), typeof(SparkViewRenderer <>));
            });

            registry
            .Views
            .Facility(new SparkViewFacility(factory, resolver))
            .TryToAttach(x => x.by(new ActionAndViewMatchedBySparkViewDescriptors(resolver, visitorRegistry)));

            return(registry);
        }
Example #7
0
        public static FubuRegistry Spark(this FubuRegistry registry, Action<ConfigureSparkExpression> configure)
        {
            var settings = new SparkSettings()
                .AddAssembly(typeof (HtmlTag).Assembly)
                .AddAssembly(typeof(FubuPageExtensions).Assembly)
                .AddNamespace(typeof(FubuRegistryExtensions).Namespace) // Spark.Web.FubuMVC
                .AddNamespace(typeof(FubuPageExtensions).Namespace) // FubuMVC.Core.UI
                .AddNamespace(typeof(HtmlTag).Namespace); // HtmlTags

            var policies = new List<ISparkPolicy>();
            var visitors = new List<ISparkDescriptorVisitor>();

            var expression = new ConfigureSparkExpression(settings, policies, visitors);

            // TODO -- this shouldn't be assuming the location of the package folder.
            // go through the front end and get this out of the package
            PackageRegistry.Packages.Each(package => registerViewFolder(expression, package));

            configure(expression);

            var factory = new SparkViewFactory(settings);
            var resolver = new SparkPolicyResolver(policies);
            var visitorRegistry = new SparkDescriptorVisitorRegistry(visitors);

            registry
                .Services(c =>
                {
                    c.SetServiceIfNone<ISparkViewFactory>(factory);
                    c.SetServiceIfNone(factory.Settings);
                    c.SetServiceIfNone(typeof(ISparkViewRenderer<>), typeof(SparkViewRenderer<>));
                });

            registry
                .Views
                .Facility(new SparkViewFacility(factory, resolver))
                .TryToAttach(x => x.by(new ActionAndViewMatchedBySparkViewDescriptors(resolver, visitorRegistry)));

            return registry;
        }
Example #8
0
        public HelloSparkRegistry(SparkViewFactory factory)
            : base(factory)
        {
            IncludeDiagnostics(true);

            AddViewFolder("/Features/");

            Actions
                .IncludeTypesNamed(x => x.EndsWith("Controller"));

            Routes
                .UrlPolicy<HelloSparkUrlPolicy>();

            SparkPolicies
                .AttachViewsBy(call => call.HandlerType.Name.EndsWith("Controller"),
                                    call => call.HandlerType.Name.RemoveSuffix("Controller"), call => call.Method.Name);

            Output.ToJson.WhenTheOutputModelIs<JsonResponse>();
            Output.To(call => new JavaScriptOutputNode(GetJavaScriptViewToken(call), call))
                .WhenTheOutputModelIs<JavaScriptResponse>();

            HomeIs<AirController>(c => c.TakeABreath());
        }
 public ViewEngineResult(ISparkView view, SparkViewFactory factory)
 {
     View = view;
     Factory = factory;
 }
Example #10
0
 public ViewEngineResult(ISparkView view, SparkViewFactory factory)
 {
     View    = view;
     Factory = factory;
 }