public LoadConfiguration(DirectoryInfo configurationDirectory, CompositionContainer container) { _container = container; _configurationDirectories = new List<DirectoryInfo>(); _configurationDirectories.Add(configurationDirectory); Configurations = new ConfigurationPart[] {}; }
public LoadConfiguration(DirectoryInfo configurationDirectory, CompositionContainer container) { _container = container; _configurationDirectories = new List <DirectoryInfo>(); _configurationDirectories.Add(configurationDirectory); Configurations = new ConfigurationPart[] {}; }
public void Load() { var previousConfigurations = Configurations; var markerType = typeof(Marker); var filesForEachConfiguration = _configurationDirectories.SelectMany(c => c.GetFiles()) .Where(f => FullTypeNameDeclaration.IsMatch(f.Name)) .GroupBy(c => Type.GetType(c.Name, false, true) ?? markerType) .ToDictionary(g => g.Key); if (filesForEachConfiguration.ContainsKey(markerType)) { var message = string.Format("No types found for files {0}", string.Join(", ", filesForEachConfiguration[markerType].Select(f => f.FullName).ToArray())); throw new InvalidOperationException(message); } Configurations = filesForEachConfiguration .Select((filesForType) => ConfigurationPart.FromFiles(filesForType.Key, filesForType.Value)) .Where(r => r != null) .ToList(); _container.Compose(new CompositionBatch(Configurations, previousConfigurations)); }