/// <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 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>()); }
/// <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()); }
/// <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)); }