public IDictionary <string, FileBased <IPackageDescriptor> > ReadAll(IDirectory directoryToReadFrom)
        {
            var descriptorFiles = (from dir in directoryToReadFrom.AncestorsAndSelf()
                                   let descriptors = dir.Files("*.wrapdesc")
                                                     where descriptors.Count() > 0
                                                     select descriptors.OrderBy(x => x.Name.Length)).FirstOrDefault();
            var all = new Dictionary <string, FileBased <IPackageDescriptor> >();

            if (descriptorFiles == null)
            {
                return(all);
            }

            var root           = descriptorFiles.First();
            var rootDescriptor = root.ReadRetry(Read);

            all[string.Empty] = FileBased.New(root, rootDescriptor);
            foreach (var descriptor in descriptorFiles.Skip(1))
            {
                var regex      = new Regex(string.Format("^{0}.(?<scope>.*).wrapdesc$", rootDescriptor.Name));
                var scopeMatch = regex.Match(descriptor.Name);
                if (scopeMatch.Success == false)
                {
                    continue;
                }
                var scopedDescriptor = rootDescriptor
                                       .CreateScoped(descriptor.Read(Read));
                all[scopeMatch.Groups["scope"].Value] = FileBased.New(descriptor, scopedDescriptor);
            }
            return(all);
        }
Example #2
0
 public static IDirectory FindProjectRepositoryDirectory(this IDirectory root)
 {
     return(root == null
                    ? null
                    : root.AncestorsAndSelf()
            .SelectMany(x => x.Directories("wraps"))
            .Where(x => x != null)
            .FirstOrDefault());
 }