public Dictionary <T, MetadataCollection> Generate() { var dataDirectory = Path.GetFullPath(PathResolver.DataDirectory(MetadataResolver.DataDirectoryToOperateIn)); if (!Directory.Exists(dataDirectory)) { Logger.Warning($"Unable to find directory {dataDirectory}"); return(new Dictionary <T, MetadataCollection>()); } var tidier = new FileTidier(); tidier.ParseDirectory(dataDirectory); Logger.Info($"Parsing {MetadataResolver.EntityTypeName} data"); var yaml = new YamlToBaseDataMapper <T>(Logger, MetadataResolver); yaml.ParseDirectory(dataDirectory); return(yaml.ParsedEntitiesMetadata); }
public void Operate() { var files = Directory.GetFiles(PathResolver.DataDirectory(MetadataResolver.DataDirectoryToOperateIn), "*.yaml"); foreach (var file in files) { var fileInfo = new FileInfo(file); var name = Path.GetFileNameWithoutExtension(fileInfo.Name); var typeEntity = Entities.Keys.FirstOrDefault(i => MetadataResolver.GetEntityId(i).ToLower() == name.ToLower()); if (typeEntity == null) { Logger.Warning($"Unable to find corresponding {MetadataResolver.EntityTypeName} yaml file for {name}"); } else { var category = MetadataResolver.GetEntityCategory(typeEntity); if (string.IsNullOrEmpty(category)) { continue; } var targetDirectory = PathResolver.DataDirectory(MetadataResolver.DataDirectoryToOperateIn, category); if (!Directory.Exists(targetDirectory)) { Directory.CreateDirectory(targetDirectory); } var old = fileInfo.FullName; var newF = Path.Combine(targetDirectory, fileInfo.Name); fileInfo.MoveTo(newF); Logger.LogSection("Moved yaml Files", $"{old} -> {newF}"); } } }