private IEnumerable<JavaPackage> GetPackagesInFolder(string folder) { string[] dirs = Directory.GetDirectories(folder, "*.*", SearchOption.AllDirectories); foreach (string dir in dirs) { string[] files = Directory.GetFiles(dir, "*.java"); if (files.Length > 0) { string packageName = dir.Substring(folder.Length).Replace(@"\", "."); JavaPackage package = new JavaPackage(packageName, dir); package.AddFiles(files.Select(file => new JavaCodeFile(package, Path.GetFileName(file)))); yield return package; } } }
public JavaCodeFile(JavaPackage package, string name) { Package = package; Name = name; }