public MemoryGloballist Perform( Expression_Node_Filepath expr_Fpath_GloballistText, Encoding encoding, Log_Reports log_Reports, string sRunningHintName ) { Log_Method pg_Method = new Log_MethodImpl(0); pg_Method.BeginMethod(Info_Operating.Name_Library, this, "Perform",log_Reports); MemoryGloballist moGl = new MemoryGloballistImpl(); string sFpatha = expr_Fpath_GloballistText.Execute4_OnExpressionString( EnumHitcount.Unconstraint, log_Reports);//絶対ファイルパス if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } if ("" == sFpatha) { // グローバルリスト ファイルへのパスが空文字列だった場合 if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー080011!", pg_Method); r.Message = "グローバルリスト ファイルへのパスを指定してください。"; log_Reports.EndCreateReport(); } } string sText1; if (log_Reports.Successful) { // 正常時 // テキスト読取り try { sText1 = System.IO.File.ReadAllText(sFpatha, encoding); } catch(Exception ex) { sText1 = null; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー0800023!", pg_Method); StringBuilder t = new StringBuilder(); t.Append("ファイルの読み取りに失敗しました。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("ファイルパス=["); t.Append(sFpatha); t.Append("]"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("エンコーディング=["); t.Append(encoding.ToString()); t.Append("]"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("例外:["); t.Append(ex.GetType().Name); t.Append("]:"); t.Append(ex.Message); r.Message = t.ToString(); log_Reports.EndCreateReport(); } } } else { // エラー時 sText1 = null; } if (log_Reports.Successful) { // 正常時 // テキストをストリーム化します。 System.IO.StringReader reader = new System.IO.StringReader(sText1); while (-1 < reader.Peek()) { string sLine = reader.ReadLine(); string parent_SNode = sFpatha; MemoryGloballistLine modelOfGlLine = this.Sub_ParseLine(sLine, log_Reports, parent_SNode); if (log_Reports.Successful) { // 正常時 moGl.AddLine(modelOfGlLine); } } // ストリームを閉じます。 reader.Close(); } // // // // gt_EndMethod: pg_Method.EndMethod(log_Reports); return moGl; }
public MemoryGloballist Perform( Expression_Node_Filepath expr_Fpath_GloballistText, Encoding encoding, Log_Reports log_Reports, string sRunningHintName ) { Log_Method pg_Method = new Log_MethodImpl(0); pg_Method.BeginMethod(Info_Operating.Name_Library, this, "Perform", log_Reports); MemoryGloballist moGl = new MemoryGloballistImpl(); string sFpatha = expr_Fpath_GloballistText.Execute4_OnExpressionString( EnumHitcount.Unconstraint, log_Reports);//絶対ファイルパス if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } if ("" == sFpatha) { // グローバルリスト ファイルへのパスが空文字列だった場合 if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー080011!", pg_Method); r.Message = "グローバルリスト ファイルへのパスを指定してください。"; log_Reports.EndCreateReport(); } } string sText1; if (log_Reports.Successful) { // 正常時 // テキスト読取り try { sText1 = System.IO.File.ReadAllText(sFpatha, encoding); } catch (Exception ex) { sText1 = null; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー0800023!", pg_Method); StringBuilder t = new StringBuilder(); t.Append("ファイルの読み取りに失敗しました。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("ファイルパス=["); t.Append(sFpatha); t.Append("]"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("エンコーディング=["); t.Append(encoding.ToString()); t.Append("]"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); t.Append("例外:["); t.Append(ex.GetType().Name); t.Append("]:"); t.Append(ex.Message); r.Message = t.ToString(); log_Reports.EndCreateReport(); } } } else { // エラー時 sText1 = null; } if (log_Reports.Successful) { // 正常時 // テキストをストリーム化します。 System.IO.StringReader reader = new System.IO.StringReader(sText1); while (-1 < reader.Peek()) { string sLine = reader.ReadLine(); string parent_SNode = sFpatha; MemoryGloballistLine modelOfGlLine = this.Sub_ParseLine(sLine, log_Reports, parent_SNode); if (log_Reports.Successful) { // 正常時 moGl.AddLine(modelOfGlLine); } } // ストリームを閉じます。 reader.Close(); } // // // // gt_EndMethod: pg_Method.EndMethod(log_Reports); return(moGl); }