Core.LoadConfiguration.Load C# (CSharp) Method

Load() public method

public Load ( ) : void
return void
        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));
        }