Inheritance: IConfiguration
Exemplo n.º 1
0
        public void Compose(BaseParameters parameters)
        {
            try
            {
                var catalog = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly()),
                                                   new AssemblyCatalog(typeof(Logic.SanityCheck).Assembly));

                LoadPlugins(catalog, parameters);

                var container = new CompositionContainer(catalog);

                var batch = new CompositionBatch();
                batch.AddPart(this);
                batch.AddPart(parameters);

                var config = new Configuration(parameters.FileSystem, parameters.Path);
                config.ReadFromFile();
                batch.AddExportedValue((IConfiguration)config);

                container.Compose(batch);
            }
            catch (ReflectionTypeLoadException ex)
            {
                Console.WriteLine(@"Unable to load: \r\n{0}",
                    string.Join("\r\n", ex.LoaderExceptions.Select(e => e.Message)));

                throw;
            }
        }
Exemplo n.º 2
0
        public ConfigurationTests()
        {
            var fileSystem = new MockFileSystem();
            fileSystem.AddFile(@"C:\WebSite\_config.yml", new MockFileData(SampleConfig));

            _sut = new Configuration(fileSystem, @"C:\WebSite");
            _sut.ReadFromFile();
        }
Exemplo n.º 3
0
        public void page_frontmatter_should_have_priority_over_defaults_in_config()
        {
            // Arrange
            fileSystem.AddFile(@"C:\TestSite\_config.yml", new MockFileData(@"
            defaults:
              -
            scope:
              path: ''
            values:
              author: 'default-author'
            "));

            fileSystem.AddFile(@"C:\TestSite\about.md", new MockFileData(@"---
            author: 'page-specific-author'
            ---
            # About page
            "));

            var config = new Configuration(fileSystem, @"C:\TestSite");
            config.ReadFromFile();
            var sut = new SiteContextGenerator(fileSystem, new LinkHelper(), config);

            // Act
            var siteContext = sut.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false);

            // Assert
            Assert.Equal("page-specific-author", siteContext.Pages[0].Bag["author"]);
        }
Exemplo n.º 4
0
        public void defaults_in_config_should_be_combined_with_page_frontmatter_in_page_bag()
        {
            // Arrange
            fileSystem.AddFile(@"C:\TestSite\_config.yml", new MockFileData(@"
            defaults:
              -
            scope:
              path: ''
            values:
              author: 'default-author'
            "));

            fileSystem.AddFile(@"C:\TestSite\about.md", new MockFileData(@"---
            title: 'about'
            ---
            # About page
            "));

            var config = new Configuration(fileSystem, @"C:\TestSite");
            config.ReadFromFile();
            var sut = new SiteContextGenerator(fileSystem, new LinkHelper(), config);

            // Act
            var siteContext = sut.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false);

            // Assert
            Assert.Equal("about", siteContext.Pages[0].Bag["title"]); // from page frontmatter
            Assert.Equal("default-author", siteContext.Pages[0].Bag["author"]); // from config defaults
        }