コード例 #1
0
        static public PartSeederFactory GetFactory()
        {
            // map
            TagAttributeToTypeMap map = new TagAttributeToTypeMap();

            map.Add(new[]
            {
                // Cadmus.Core
                typeof(StandardItemSortKeyBuilder).Assembly,
                // Cadmus.Tgr.Parts
                typeof(LingTagsLayerFragment).Assembly
            });

            // container
            Container container = new Container();

            PartSeederFactory.ConfigureServices(
                container,
                new StandardPartTypeProvider(map),
                new[]
            {
                // Cadmus.Seed.Tgr.Parts
                typeof(LingTagsLayerFragmentSeeder).Assembly
            });

            // config
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .AddInMemoryJson(LoadResourceText("SeedConfig.json"));
            var configuration = builder.Build();

            return(new PartSeederFactory(container, configuration));
        }
コード例 #2
0
        /// <summary>
        /// Gets the part/fragment seeders factory.
        /// </summary>
        /// <param name="profile">The profile.</param>
        /// <returns>Factory.</returns>
        /// <exception cref="ArgumentNullException">profile</exception>
        public PartSeederFactory GetFactory(string profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException(nameof(profile));
            }

            // build the tags to types map for parts/fragments
            Assembly[] seedAssemblies = new[]
            {
                // Cadmus.Seed.Parts
                typeof(NotePartSeeder).Assembly,
                // Cadmus.Seed.Philology.Parts
                typeof(ApparatusLayerFragmentSeeder).Assembly,
                // Cadmus.Seed.Itinera.Parts
                typeof(MsSignaturesPartSeeder).Assembly,
                // Cadmus.Seed.Tgr.Parts
                typeof(LingTagsLayerFragmentSeeder).GetTypeInfo().Assembly,
                // Cadmus.Seed.Pura.Parts
                typeof(WordFormsPartSeeder).GetTypeInfo().Assembly,
            };
            TagAttributeToTypeMap map = new TagAttributeToTypeMap();

            map.Add(seedAssemblies);

            // build the container for seeders
            Container container = new Container();

            PartSeederFactory.ConfigureServices(
                container,
                new StandardPartTypeProvider(map),
                seedAssemblies);

            container.Verify();

            // load seed configuration
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .AddInMemoryJson(profile);
            var configuration = builder.Build();

            return(new PartSeederFactory(container, configuration));
        }
コード例 #3
0
        public PartSeederFactory GetFactory(string profilePath)
        {
            if (profilePath == null)
            {
                throw new ArgumentNullException(nameof(profilePath));
            }

            // build the tags to types map for parts/fragments
            TagAttributeToTypeMap map = new TagAttributeToTypeMap();
            string pluginDir          = Path.Combine(
                Directory.GetCurrentDirectory(), "Plugins");

            map.Add(
                pluginDir,
                "*parts*.dll",
                new PluginLoadContext(pluginDir));

            // build the container for seeders
            Container container      = new Container();
            var       seedAssemblies = LoadSeedAssemblies(
                Path.Combine(Directory.GetCurrentDirectory(), "Plugins"));

            // configure the seeders container
            PartSeederFactory.ConfigureServices(
                container,
                new StandardPartTypeProvider(map),
                seedAssemblies.ToArray());

            container.Verify();

            // load seed config
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .AddJsonFile(profilePath);
            var configuration = builder.Build();

            return(new PartSeederFactory(container, configuration));
        }