Inheritance: System.ComponentModel.Composition.Primitives.ComposablePart
 public LoadConfiguration(DirectoryInfo configurationDirectory, CompositionContainer container)
 {
     _container = container;
     _configurationDirectories = new List<DirectoryInfo>();
     _configurationDirectories.Add(configurationDirectory);
     Configurations = new ConfigurationPart[] {};
 }
Esempio n. 2
0
 public LoadConfiguration(DirectoryInfo configurationDirectory, CompositionContainer container)
 {
     _container = container;
     _configurationDirectories = new List <DirectoryInfo>();
     _configurationDirectories.Add(configurationDirectory);
     Configurations = new ConfigurationPart[] {};
 }
Esempio n. 3
0
        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));
        }