private static Configuration LoadAllFilesFromChain(string path, string resourcePostfix, IConfigurationInterpreter interpreter)
        {
            var files = new List<FileInfo>();

            var d = new DirectoryInfo(path);
            do
            {
                var userConfig =
                    d.GetFiles()
                        .Where(r => r.Name.EndsWith(resourcePostfix, StringComparison.OrdinalIgnoreCase))
                        .OrderByDescending(c => c.Name);

                files.AddRange(userConfig);
                d = d.Parent;
            } while (d != null);

            files.Reverse();

            return files.Select(c => File.ReadAllText(c.FullName))
                        .Aggregate(new Configuration(), (current, resource) =>
                        {
                            var obj = interpreter.ParseConfiguration(resource);
                            return current.UpdateWith(obj);
                        });
        }
Beispiel #2
0
        private static Configuration LoadAllFilesFromChain(string path, string resourcePostfix, IConfigurationInterpreter interpreter)
        {
            var files = new List <FileInfo>();

            var d = new DirectoryInfo(path);

            do
            {
                var userConfig =
                    d.GetFiles()
                    .Where(r => r.Name.EndsWith(resourcePostfix, StringComparison.OrdinalIgnoreCase))
                    .OrderByDescending(c => c.Name);

                files.AddRange(userConfig);
                d = d.Parent;
            } while (d != null);

            files.Reverse();

            return(files.Select(c => File.ReadAllText(c.FullName))
                   .Aggregate(new Configuration(), (current, resource) =>
            {
                var obj = interpreter.ParseConfiguration(resource);
                return current.UpdateWith(obj);
            }));
        }
 private static Configuration GetExpandoFromAssemblies(IEnumerable<Assembly> assemblies, string resourcePostfix, IConfigurationInterpreter interpreter)
 {
     return assemblies.SelectMany(assembly => ReadEmbededResources(assembly, resourcePostfix)).Aggregate(new Configuration(), (current, resource) =>
     {
         var obj = interpreter.ParseConfiguration(resource);
         return current.UpdateWith(obj);
     });
 }
 private static Configuration GetExpandoFromAssemblies(IEnumerable <Assembly> assemblies, string resourcePostfix, IConfigurationInterpreter interpreter)
 {
     return(assemblies.SelectMany(assembly => ReadEmbededResources(assembly, resourcePostfix)).Aggregate(new Configuration(), (current, resource) =>
     {
         var obj = interpreter.ParseConfiguration(resource);
         return current.UpdateWith(obj);
     }));
 }