示例#1
0
        public static DefaultDescriptorBuilder CreateSparkDescriptorBuilder()
        {
            var builder = new DefaultDescriptorBuilder();

            builder.Filters.Add(new AreaDescriptorFilter());
            return(builder);
        }
        public void SimplifiedUseMasterGrammarWithPrefixDetectsElementCorrectly()
        {
            var builder = new DefaultDescriptorBuilder("s");

            var a    = builder.ParseUseMaster(new Position(new SourceContext("<s:use master='a'/>")));
            var b    = builder.ParseUseMaster(new Position(new SourceContext("<s:use\r\nmaster \r\n =\r\n'b' />")));
            var c    = builder.ParseUseMaster(new Position(new SourceContext("<s:use master=\"c\"/>")));
            var def  = builder.ParseUseMaster(new Position(new SourceContext("  x <s:use etc=''/> <s:use master=\"def\"/> y ")));
            var none = builder.ParseUseMaster(new Position(new SourceContext("  x <s:use etc=''/> <using master=\"def\"/> y ")));
            var g    = builder.ParseUseMaster(new Position(new SourceContext("-<s:use master=\"g\"/>-<s:use master=\"h\"/>-")));


            Assert.That(a.Value, Is.EqualTo("a"));
            Assert.That(b.Value, Is.EqualTo("b"));
            Assert.That(c.Value, Is.EqualTo("c"));
            Assert.That(def.Value, Is.EqualTo("def"));
            Assert.That(none, Is.Null);
            Assert.That(g.Value, Is.EqualTo("g"));
        }
示例#3
0
        public void Descriptors_with_simplified_use_master_grammar_should_detect_element_correctly()
        {
            //Given
            var builder = new DefaultDescriptorBuilder();

            //When
            var a    = builder.ParseUseMaster(new Position(new SourceContext("<use master='a'/>")));
            var b    = builder.ParseUseMaster(new Position(new SourceContext("<use\r\nmaster \r\n =\r\n'b' />")));
            var c    = builder.ParseUseMaster(new Position(new SourceContext("<use master=\"c\"/>")));
            var def  = builder.ParseUseMaster(new Position(new SourceContext("  x <use etc=''/> <use master=\"def\"/> y ")));
            var none = builder.ParseUseMaster(new Position(new SourceContext("  x <use etc=''/> <using master=\"def\"/> y ")));
            var g    = builder.ParseUseMaster(new Position(new SourceContext("-<use master=\"g\"/>-<use master=\"h\"/>-")));

            //Then
            a.Value.ShouldEqual("a");
            b.Value.ShouldEqual("b");
            c.Value.ShouldEqual("c");
            def.Value.ShouldEqual("def");
            none.ShouldBeNull();
            g.Value.ShouldEqual("g");
        }
示例#4
0
        public static DefaultDescriptorBuilder CreateSparkDescriptorBuilder()
        {
            var builder = new DefaultDescriptorBuilder();

            return(builder);
        }
示例#5
0
        public void SimplifiedUseMasterGrammarWithPrefixDetectsElementCorrectly()
        {
            var builder = new DefaultDescriptorBuilder("s");

            var a = builder.ParseUseMaster(new Position(new SourceContext("<s:use master='a'/>")));
            var b = builder.ParseUseMaster(new Position(new SourceContext("<s:use\r\nmaster \r\n =\r\n'b' />")));
            var c = builder.ParseUseMaster(new Position(new SourceContext("<s:use master=\"c\"/>")));
            var def = builder.ParseUseMaster(new Position(new SourceContext("  x <s:use etc=''/> <s:use master=\"def\"/> y ")));
            var none = builder.ParseUseMaster(new Position(new SourceContext("  x <s:use etc=''/> <using master=\"def\"/> y ")));
            var g = builder.ParseUseMaster(new Position(new SourceContext("-<s:use master=\"g\"/>-<s:use master=\"h\"/>-")));

            Assert.That(a.Value, Is.EqualTo("a"));
            Assert.That(b.Value, Is.EqualTo("b"));
            Assert.That(c.Value, Is.EqualTo("c"));
            Assert.That(def.Value, Is.EqualTo("def"));
            Assert.That(none, Is.Null);
            Assert.That(g.Value, Is.EqualTo("g"));
        }
示例#6
0
        public void EmptyPrefixIsConsideredNoPrefixAtAll()
        {
            var builder = new DefaultDescriptorBuilder(string.Empty);

              var a = builder.ParseUseMaster(new Position(new SourceContext("<use master='a'/>")));

              Assert.That(a, Is.Not.Null);
              Assert.That(a.Value, Is.EqualTo("a"));
        }
 public static void AddFilter(this DefaultDescriptorBuilder target, IDescriptorFilter filter)
 {
     target.Filters.Add(filter);
 }
示例#8
0
        public static void Main(string[] args)
        {
            var    location = typeof(AscendApplication).Assembly.Location;
            string target   = Path.ChangeExtension(location, ".Views.dll");
            string root     = Path.GetDirectoryName(Path.GetDirectoryName(location));

            //string webBinPath = Path.Combine (directoryName, "bin");

            Console.WriteLine("Precompiling to target: {0}", target);
            Console.WriteLine("Root folder: {0}", root);

            try
            {
                var factory = new SparkViewFactory(AscendApplication.CreateSparkSettings());
                factory.ViewFolder        = new VirtualPathCompatableViewFolder(root);
                factory.Engine.ViewFolder = factory.ViewFolder;

                var builder = new DefaultDescriptorBuilder(factory.Engine);
                builder.Filters.Add(new Ascend.Web.AreaDescriptorFilter());
                factory.DescriptorBuilder = builder;

                var batch = new SparkBatchDescriptor(target);
                batch.FromAssembly(typeof(AscendApplication).Assembly);

                var descriptors = new List <SparkViewDescriptor>();
                foreach (var entry in batch.Entries)
                {
                    var t     = entry.ControllerType;
                    var name  = t.Name.Substring(0, t.Name.Length - ("Controller".Length));
                    var parts = t.Namespace.Split('.');
                    var area  = parts[1 + Array.LastIndexOf(parts, "Areas")];

                    foreach (var view in factory.ViewFolder.ListViews(Path.Combine(root, "Areas", area, "Views", name)))
                    {
                        var locations  = new List <string>();
                        var descriptor = factory.DescriptorBuilder.BuildDescriptor(
                            new BuildDescriptorParams(
                                t.Namespace,
                                name,
                                Path.GetFileNameWithoutExtension(view),
                                null,
                                true,
                                new Dictionary <string, object>  {
                            { "area", area }
                        }),
                            locations);
                        descriptors.Add(descriptor);
                    }
                }

                var result = factory.Engine.BatchCompilation(target, descriptors);

                // var descriptors = factory.CreateDescriptors(batch);
                // factory.Precompile(batch);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw ex;
            }
        }