예제 #1
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)));
        }
예제 #2
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;
        }