/// <summary> /// Gets all types that should be transpiled according to the specified configuration. /// </summary> /// <param name="configurationSource">Source for the configuration that should be used.</param> /// <returns>A sequence with the types that should be transpiled according to the specified configuration.</returns> public IEnumerable <Type> GetTypesByConfiguration(IConfigurationSource configurationSource) { if (configurationSource == null) { throw new ArgumentNullException(nameof(configurationSource)); } EnsureNotDisposed(); var configuration = configurationSource.GetRequiredSection <InputConfiguration>(); var assemblyFiles = configuration.AssemblyFiles .SelectMany(x => new DirectoryInfo(Environment.CurrentDirectory) .EnumerateFiles(x, SearchOption.AllDirectories) .Select(f => f.FullName)); return(assemblyFiles.SelectMany(GetTypesFromAssembly) .Where(configuration.TypeFilter.IsMatch)); }
/// <summary> /// Creates an <see cref="ICodeWriter"/> for the specified configuration. /// </summary> /// <param name="configurationSource">Source for the configuration that should be used.</param> /// <returns>An instance of <see cref="ICodeWriter"/> for the specified configuration.</returns> public static ICodeWriter FromConfiguration(IConfigurationSource configurationSource) { if (configurationSource == null) { throw new ArgumentNullException(nameof(configurationSource)); } var configuration = configurationSource.GetRequiredSection <OutputConfiguration>(); var writers = new List <ICodeWriter>(); if (!string.IsNullOrWhiteSpace(configuration.BundledFile)) { writers.Add(new BundledFileCodeWriter(configuration.BundledFile)); } if (configuration.Files != null) { writers.Add(new FileCodeWriter(configuration.Files.Directory, configuration.Files.MimicNamespacesWithSubdirectories)); } return(new CompositeCodeWriter(writers)); }
public void ConfigurationSourceExtensions_GetRequiredSectionThrowsArgumentNullException() { IConfigurationSource source = null; Assert.Throws <ArgumentNullException>(() => source.GetRequiredSection <ConfigurationSection>()); }