using System.Collections.Generic; using System.Linq; namespace FluentTerminal.App.Services.Implementation { public class ThemeParserFactory : IThemeParserFactory { private readonly IEnumerable _parsers; public IEnumerable SupportedFileTypes { get; } public ThemeParserFactory(IEnumerable parsers) { _parsers = parsers; SupportedFileTypes = _parsers.SelectMany(p => p.SupportedFileTypes); } public IThemeParser GetParser(string fileType) { return _parsers.FirstOrDefault(p => p.SupportedFileTypes.Contains(fileType)); } } }