private void applyGlobalTransforms(ContentPlan plan)
        {
            var globalPolicies = _library.FindGlobalPoliciesFor(plan.MimeType);
            globalPolicies.Each(policy =>
            {
                if (policy.MustBeBatched())
                {
                    plan.CombineAll();
                }

                plan.GetAllSources().Each(s => plan.ApplyTransform(s, policy.TransformerType));
            });
        }
示例#2
0
        private void applyGlobalTransforms(ContentPlan plan)
        {
            var globalPolicies = _library.FindGlobalPoliciesFor(plan.MimeType);
            globalPolicies.Each(policy =>
            {
                if (policy.MustBeBatched())
                {
                    plan.CombineAll();
                }

                plan.GetAllSources().Each(s => plan.ApplyTransform(s, policy.TransformerType));
            });
        }
示例#3
0
        public void constructor_sets_up_the_default_content_sources_for_each_file()
        {
            var files = new AssetFile[]{
                new AssetFile("something.js"){FullPath = "something.js"},
                new AssetFile("something2.js"){FullPath = "something2.js"},
                new AssetFile("something3.js"){FullPath = "something3.js"},
                new AssetFile("something4.js"){FullPath = "something4.js"},
            };

            var plan = new ContentPlan("a plan", files);

            plan.GetAllSources().ShouldHaveTheSameElementsAs(files.Select(x => new FileRead(x)));
        }
示例#4
0
        private static void applyBatchedNonGlobalTransforms(ContentPlan plan, TransformerRequirements requirements)
        {
            var policy = findBatchedTransformerPolicy(requirements);
            if (policy == null) return;

            var groups = new AssetGrouper<IContentSource>()
                .GroupSubjects(plan.GetAllSources(), source => requirements.IsNextPolicy(source, policy));

            groups.Each(group =>
            {
                if (group.Count == 1)
                {
                    plan.ApplyTransform(group.Single(), policy.TransformerType);
                }
                else
                {
                    var combo = plan.Combine(group);
                    plan.ApplyTransform(combo, policy.TransformerType);
                }

                group.Each(s => requirements.DequeueTransformer(s, policy));
            });
        }
示例#5
0
        private static void applyBatchedNonGlobalTransforms(ContentPlan plan, TransformerRequirements requirements)
        {
            var policy = findBatchedTransformerPolicy(requirements);
            if (policy == null) return;


            var groups = new AssetGrouper<IContentSource>()
                .GroupSubjects(plan.GetAllSources(), source => requirements.IsNextPolicy(source, policy));

            groups.Each(group =>
            {
                if (group.Count == 1)
                {
                    plan.ApplyTransform(group.Single(), policy.TransformerType);
                }
                else
                {
                    var combo = plan.Combine(group);
                    plan.ApplyTransform(combo, policy.TransformerType);
                }

                group.Each(s => requirements.DequeueTransformer(s, policy));
            });
        }
        public void try_it_against_a_3_deep_hierarchy()
        {
            var theFiles = new AssetFile[]{
                new AssetFile("a.js"){FullPath = "a.js"},
                new AssetFile("b.js"){FullPath = "b.js"},
                new AssetFile("c.js"){FullPath = "c.js"},
                new AssetFile("d.js"){FullPath = "d.js"},
            };

            var plan = new ContentPlan("something", theFiles);
            var read0 = plan.GetAllSources().ElementAt(0);
            var read1 = plan.GetAllSources().ElementAt(1);
            var read2 = plan.GetAllSources().ElementAt(2);
            var read3 = plan.GetAllSources().ElementAt(3);

            var combo1 = plan.Combine(new IContentSource[] { read1, read2 });
            var combo2 = plan.Combine(new IContentSource[] { read0, combo1, read3 });

            var previewer = new ContentPlanPreviewer();
            plan.AcceptVisitor(previewer);

            previewer.WriteToDebug();

            var expected = new StringBuilder()
                .AppendLine("Combination")
                .AppendLine("  FileRead:a.js")
                .AppendLine("  Combination")
                .AppendLine("    FileRead:b.js")
                .AppendLine("    FileRead:c.js")
                .Append("  FileRead:d.js");

            previewer.ToFullDescription().ShouldEqual(expected);
        }
示例#7
0
        public void SetUp()
        {
            files = new AssetFile[]{
                new AssetFile("something.js"){FullPath = "something.js"},
                new AssetFile("something2.js"){FullPath = "something2.js"},
                new AssetFile("something3.js"){FullPath = "something3.js"},
                new AssetFile("something4.js"){FullPath = "something4.js"},
            };

            thePlan = new ContentPlan("a plan", files);
            theCombination = thePlan.Combine(new[] { thePlan.GetAllSources().ElementAt(0), thePlan.GetAllSources().ElementAt(1) });
        }
示例#8
0
        public void SetUp()
        {
            files = new AssetFile[]{
                new AssetFile("something.js"){FullPath = "something.js"},
                new AssetFile("something2.js"){FullPath = "something2.js"},
                new AssetFile("something3.js"){FullPath = "something3.js"},
                new AssetFile("something4.js"){FullPath = "something4.js"},
            };

            thePlan = new ContentPlan("a plan", files);
            theReadFileSource = thePlan.GetAllSources().ElementAt(2);
            theTransformerNode = thePlan.ApplyTransform(theReadFileSource, typeof(StubTransformer));
        }