/// <summary>
        /// Gets the part seeders from <c>seed/partSeeders</c>.
        /// </summary>
        /// <returns>Dictionary where each key is a part type ID, and each
        /// value is the corresponding seeder.</returns>
        public Dictionary <string, IPartSeeder> GetPartSeeders()
        {
            IList <ComponentFactoryConfigEntry> entries =
                ComponentFactoryConfigEntry.ReadComponentEntries(
                    Configuration, "seed:partSeeders");

            SeedOptions options = GetSeedOptions();

            IList <IPartSeeder> seeders =
                GetComponents <IPartSeeder>(entries, false, true);

            int i = 0;
            Dictionary <string, IPartSeeder> result =
                new Dictionary <string, IPartSeeder>();

            foreach (IPartSeeder seeder in seeders)
            {
                string id = entries[i++].Id;
                id = id.Substring("seed.".Length);

                seeder.SetSeedOptions(options);
                result[id] = seeder;
            }

            return(result);
        }
        /// <summary>
        /// Gets the fragment seeder for the specified fragment type ID,
        /// which is located in <c>seed:fragmentSeeders</c>.
        /// </summary>
        /// <param name="typeId">The fragment seeder type ID.</param>
        /// <returns>Seeder, or null if not found.</returns>
        /// <exception cref="ArgumentNullException">typeId</exception>
        public IFragmentSeeder GetFragmentSeeder(string typeId)
        {
            if (typeId == null)
            {
                throw new ArgumentNullException(nameof(typeId));
            }

            var entry = ComponentFactoryConfigEntry.ReadComponentEntry(
                Configuration, "seed:fragmentSeeders", typeId);

            if (entry == null)
            {
                return(null);
            }

            SeedOptions options = GetSeedOptions();

            IFragmentSeeder seeder = GetComponent <IFragmentSeeder>(
                typeId, entry.OptionsPath, false);

            if (seeder == null)
            {
                return(null);
            }

            seeder.SetSeedOptions(options);
            return(seeder);
        }
        /// <summary>
        /// Gets the seed options from <c>/seed/options</c>.
        /// </summary>
        /// <returns>The seed options</returns>
        public SeedOptions GetSeedOptions()
        {
            IConfigurationSection section =
                Configuration.GetSection("seed")?.GetSection("options");
            SeedOptions options = section?.Get <SeedOptions>()
                                  ?? new SeedOptions();

            options.FacetDefinitions = Configuration.GetSection("facets")
                                       .Get <FacetDefinition[]>();

            return(options);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Set the general seed options.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <exception cref="ArgumentNullException">options</exception>
 public void SetSeedOptions(SeedOptions options)
 {
     Options = options ??
               throw new ArgumentNullException(nameof(options));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ItemSeeder"/> class.
 /// </summary>
 /// <param name="options">The seed options.</param>
 /// <exception cref="ArgumentNullException">options</exception>
 public ItemSeeder(SeedOptions options)
 {
     _options = options
                ?? throw new ArgumentNullException(nameof(options));
     _sortKeyBuilder = new StandardItemSortKeyBuilder();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CadmusSeeder"/> class.
 /// </summary>
 /// <param name="factory">The part seeder factory.</param>
 /// <exception cref="ArgumentNullException">factory</exception>
 public CadmusSeeder(PartSeederFactory factory)
 {
     _factory = factory
                ?? throw new ArgumentNullException(nameof(factory));
     _options = _factory.GetSeedOptions();
 }