private TagAttributeToTypeMap GetMap()
        {
            TagAttributeToTypeMap map = new TagAttributeToTypeMap();

            map.Add(new[] { typeof(NotePart).Assembly });
            return(map);
        }
Exemple #2
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));
        }
        public ICadmusRepository CreateRepository(string database)
        {
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }

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

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

            // create the repository (no need to use container here)
            MongoCadmusRepository repository = new MongoCadmusRepository(
                new StandardPartTypeProvider(map),
                new StandardItemSortKeyBuilder());

            repository.Configure(new MongoCadmusRepositoryOptions
            {
                ConnectionString = string.Format(
                    _configuration.GetConnectionString("Mongo"),
                    database)
            });

            return(repository);
        }
Exemple #4
0
        private static IPartTypeProvider GetProvider()
        {
            TagAttributeToTypeMap map = new TagAttributeToTypeMap();

            map.Add(new Assembly[] { typeof(NotePart).Assembly });
            return(new StandardPartTypeProvider(map));
        }
        public void Get_NotePart_Ok()
        {
            TagAttributeToTypeMap map = GetMap();

            Type t = map.Get("net.fusisoft.note");

            Assert.Equal(typeof(NotePart), t);
        }
        public void Get_NotExistingPart_Null()
        {
            TagAttributeToTypeMap map = GetMap();

            Type t = map.Get("not-existing");

            Assert.Null(t);
        }
        public void Get_CommentLayerPart_Ok()
        {
            TagAttributeToTypeMap map = GetMap();

            Type t = map.Get(
                "net.fusisoft.token-text-layer:fr.net.fusisoft.comment");

            Assert.Equal(typeof(TokenTextLayerPart <CommentLayerFragment>), t);
        }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppRepositoryProvider"/> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <exception cref="ArgumentNullException">configuration</exception>
        public AppRepositoryProvider(IConfiguration configuration)
        {
            _configuration = configuration ??
                             throw new ArgumentNullException(nameof(configuration));

            _map = new TagAttributeToTypeMap();
            _map.Add(new[]
            {
                // Cadmus.Parts
                typeof(NotePart).GetTypeInfo().Assembly,
                // Cadmus.Philology.Parts
                typeof(ApparatusLayerFragment).GetTypeInfo().Assembly
            });

            _partTypeProvider = new StandardPartTypeProvider(_map);
        }
Exemple #9
0
        protected override ICadmusRepository GetRepository()
        {
            TagAttributeToTypeMap map = new TagAttributeToTypeMap();

            map.Add(new[]
            {
                typeof(NotePart).Assembly
            });
            MongoCadmusRepository repository = new MongoCadmusRepository(
                new StandardPartTypeProvider(map),
                new StandardItemSortKeyBuilder());

            repository.Configure(new MongoCadmusRepositoryOptions
            {
                // use the default ConnectionStringTemplate (local DB)
                ConnectionString = "mongodb://localhost:27017/" + DB_NAME
            });
            return(repository);
        }
        /// <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));
        }
Exemple #11
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));
        }