private void CreateOutputStrsDB <Format> (List <DatabaseTypeStr> databaseTypeStrs, WoditerInfo.WoditerInfoCategory woditerInfoCategory, Format format) where Format : StrFormatBase { int count = 0; // 出力先ディレクトリ確認と作成 MakeOutputDir(woditerInfoCategory); foreach (DatabaseTypeStr databaseTypeStr in databaseTypeStrs) { List <string> outputStrs = new List <string>() { }; // 各内容をList<string>に整形して書き出し outputStrs = FormatDBContents(outputStrs, databaseTypeStr, format); // 出力先ファイルパスの設定 string outputFileName = databaseTypeStr.TypeName.Sentence; if (config.IsOutputCommonNumber) { outputFileName = $"{ databaseTypeStr.TypeID.Sentence }_{ outputFileName }"; } string outputFilePath = ForamtToOutputFilePath(woditerInfoCategory, outputFileName); // 出力 File.WriteAllLines(outputFilePath, outputStrs); count++; } AddResultMes(count, woditerInfoCategory); }
///<summary>出力ファイルパスに整形</summary> private string ForamtToOutputFilePath(WoditerInfo.WoditerInfoCategory woditerInfoCategory, string filenamePrefix) { string outputFilePath = config.GetOutputDir(woditerInfoCategory); string filename = Utils.String.FormatFilename(filenamePrefix); switch (woditerInfoCategory) { case WoditerInfo.WoditerInfoCategory.CEv: { filename += ".common"; break; } case WoditerInfo.WoditerInfoCategory.CDB: { filename += ".cdb"; break; } case WoditerInfo.WoditerInfoCategory.UDB: { filename += ".udb"; break; } case WoditerInfo.WoditerInfoCategory.SDB: { filename += ".sdb"; break; } case WoditerInfo.WoditerInfoCategory.Map: { filename += ".map"; break; } case WoditerInfo.WoditerInfoCategory.MapTree: { filename += ".maptree"; break; } case WoditerInfo.WoditerInfoCategory.TileSet: { filename += ".tileset"; break; } } filename = Utils.String.AddExtension(filename); return(outputFilePath = Path.Combine(outputFilePath, filename)); }
///<summary>出力先ディレクトリの取得</summary> public string GetOutputDir(WoditerInfo.WoditerInfoCategory woditerInfoCategory) { switch (woditerInfoCategory) { case WoditerInfo.WoditerInfoCategory.CEv: { return(CEvDumpDirPath); } case WoditerInfo.WoditerInfoCategory.CDB: { return(CDBDumpDirPath); } case WoditerInfo.WoditerInfoCategory.UDB: { return(UDBDumpDirPath); } case WoditerInfo.WoditerInfoCategory.SDB: { return(SDBDumpDirPath); } case WoditerInfo.WoditerInfoCategory.Map: { return(MapDumpDirPath); } case WoditerInfo.WoditerInfoCategory.MapTree: { return(MapTreeDumpDirPath); } case WoditerInfo.WoditerInfoCategory.TileSet: { return(TileSetDumpDirPath); } default: return(""); } }
///<summary>出力先ディレクトリの存在確認(存在しない場合は新たに作成)</summary> private void MakeOutputDir(WoditerInfo.WoditerInfoCategory woditerInfoCategory) { Utils.File.CheckDirectoryExist(config.GetOutputDir(woditerInfoCategory), "", true); }
/// <summary>アプリメッセージに出力結果を追加</summary> /// <param name="count"></param> /// <param name="woditerInfoCategory"></param> private void AddResultMes(int outputCount, WoditerInfo.WoditerInfoCategory woditerInfoCategory) { AppMesOpp.AddAppMessge($"{woditerInfoCategory.ToString()} のMarkdownを出力しました({ outputCount }件)。"); }