/// <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);
        }
Exemple #3
0
        /// <summary>
        /// Gets the text filters from <c>FilterChains/{chainId}/Filters</c>.
        /// </summary>
        /// <param name="chainId">The chain ID.</param>
        /// <returns>filters</returns>
        /// <exception cref="ArgumentNullException">chainId</exception>
        public IList <ITextFilter> GetTextFilters(string chainId)
        {
            if (chainId is null)
            {
                throw new ArgumentNullException(nameof(chainId));
            }

            IConfigurationSection section =
                Configuration.GetSection("FilterChains");

            if (!section.Exists())
            {
                return(null);
            }

            int index = 0;

            foreach (IConfigurationSection chainSection in section.GetChildren())
            {
                if (chainSection["Id"] == chainId)
                {
                    var entries = ComponentFactoryConfigEntry.ReadComponentEntries(
                        Configuration,
                        $"FilterChains:{index}:Filters");
                    return(GetComponents <ITextFilter>(entries, true, true));
                }
                index++;
            }
            return(new List <ITextFilter>());
        }
Exemple #4
0
        /// <summary>
        /// Gets the IDs of all the item browsers defined in the factory
        /// configuration.
        /// </summary>
        /// <returns>Array of IDs.</returns>
        public string[] GetItemBrowserIds()
        {
            IList <ComponentFactoryConfigEntry> entries =
                ComponentFactoryConfigEntry.ReadComponentEntries(
                    Configuration, "browsers");

            return((from e in entries select e.Id).ToArray());
        }
Exemple #5
0
        /// <summary>
        /// Gets the optional item sort key builder from
        /// <c>seed/itemSortKeyBuilder</c>. If not specified, the
        /// <see cref="StandardItemSortKeyBuilder"/> will be used.
        /// </summary>
        /// <returns>Item sort key builder.</returns>
        public IItemBrowser GetItemBrowser(string id)
        {
            IList <ComponentFactoryConfigEntry> entries =
                ComponentFactoryConfigEntry.ReadComponentEntries(
                    Configuration, "browsers");
            ComponentFactoryConfigEntry entry =
                entries.FirstOrDefault(e => e.Id == id);

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

            int i = entries.IndexOf(entry);

            return(GetComponent <IItemBrowser>(
                       id,
                       $"browsers:{i}:options",
                       false));
        }