//──────────────────────────────────────── /// <summary> /// ファイル読み込み。 /// </summary> /// <param name="ec_Fpath_Aatoolxml"></param> public void LoadFile( Expression_Node_Filepath ec_Fpath_Aatoolxml, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "LoadFile",log_Reports); // Exception err_Excp; string sFpatha_Aatoolxml = ""; if (log_Reports.Successful) { // // 『ツール設定』をクリアー。 // this.Clear(this.Owner_MemoryApplication); sFpatha_Aatoolxml = ec_Fpath_Aatoolxml.Execute4_OnExpressionString( EnumHitcount.Unconstraint, log_Reports );//絶対ファイルパス } if (log_Reports.Successful) { XmlDocument xDoc = new XmlDocument(); try { // 正常時 xDoc.Load(sFpatha_Aatoolxml); // ルート要素を取得 XmlElement xRoot = xDoc.DocumentElement; // スクリプトファイルのバージョンチェック。(バリデーター登録ファイル) ValuesAttr.Test_Codefileversion( xRoot.GetAttribute(PmNames.S_CODEFILE_VERSION.Name_Attribute), log_Reports, new Configurationtree_NodeImpl(sFpatha_Aatoolxml, null), NamesNode.S_CODEFILE_TOOL ); if (log_Reports.Successful) { // デフォルト・エディター名 this.Name_DefaultEditor = xRoot.GetAttribute(PmNames.S_DEFAULT_EDITOR.Name_Attribute); // エディター要素を列挙 System.Xml.XmlNodeList xNl_Editor = xRoot.GetElementsByTagName(NamesNode.S_EDITOR); foreach (XmlNode x_EditorNode in xNl_Editor) { if (XmlNodeType.Element == x_EditorNode.NodeType) { // // エディター要素 // MemoryAatoolxml_Editor aatool_Editor = new MemoryAatoolxml_EditorImpl(this.cur_Configuration); // // エディター要素 // XmlElement xEditor = (XmlElement)x_EditorNode; // ツール設定ファイルに記載されている、エディター名 try { aatool_Editor.Name = xEditor.GetAttribute(PmNames.S_NAME.Name_Attribute); this.Dictionary_Editor.Dictionary_Item.Add(aatool_Editor.Name, aatool_Editor); } catch (ArgumentException ex) { err_Excp = ex; goto gt_Error_DuplicatedEditorName; } // <f-set-var>要素を列挙 System.Xml.XmlNodeList xNl_Fsetvar = xEditor.GetElementsByTagName(NamesNode.S_F_SET_VAR); for (int nIndex_Fsetvar = 0; nIndex_Fsetvar < xNl_Fsetvar.Count; nIndex_Fsetvar++) { XmlNode xNode_Fsetvar = xNl_Fsetvar.Item(nIndex_Fsetvar); if (XmlNodeType.Element == xNode_Fsetvar.NodeType) { //<f-set-var>要素 Configurationtree_Node cf_Fsetvar = new Configurationtree_NodeImpl(NamesNode.S_F_SET_VAR, ec_Fpath_Aatoolxml.Cur_Configuration); //<f-set-var>要素 XmlElement xFsetvar = (XmlElement)xNode_Fsetvar; string sNamevar = xFsetvar.GetAttribute(PmNames.S_NAME_VAR.Name_Attribute); string sFolder = xFsetvar.GetAttribute(PmNames.S_FOLDER.Name_Attribute); string sValue = xFsetvar.GetAttribute(PmNames.S_VALUE.Name_Attribute); string sDescription = xFsetvar.GetAttribute(PmNames.S_DESCRIPTION.Name_Attribute); cf_Fsetvar.Dictionary_Attribute.Set(PmNames.S_NAME_VAR.Name_Pm, sNamevar, log_Reports); cf_Fsetvar.Dictionary_Attribute.Set(PmNames.S_FOLDER.Name_Pm, sFolder, log_Reports); cf_Fsetvar.Dictionary_Attribute.Set(PmNames.S_VALUE.Name_Pm, sValue, log_Reports); cf_Fsetvar.Dictionary_Attribute.Set(PmNames.S_DESCRIPTION.Name_Pm, sDescription, log_Reports); aatool_Editor.Dictionary_Fsetvar_Configurationtree.List_Child.Add(cf_Fsetvar, log_Reports); } } } } } } catch (System.IO.FileNotFoundException ex) { err_Excp = ex; goto gt_Error_NothingFile; } catch (System.Exception ex) { err_Excp = ex; goto gt_Error_Exception; } } if (log_Reports.Successful) { this.cur_Configuration = ec_Fpath_Aatoolxml.Cur_Configuration; } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_DuplicatedEditorName: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー204!", log_Method); StringBuilder s = new StringBuilder(); s.Append("『ツール設定ファイル』(tool config)読み取り中に、何らかのエラーが発生しました。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("もしかして?: <" + NamesNode.S_EDITOR + ">要素の" + PmNames.S_NAME.Name_Attribute + "属性が重複している?"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); // 例外メッセージ s.Append(r.Message_SException(err_Excp)); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_NothingFile: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, ValuesAttr.S_FPATHR_AATOOLXML,log_Reports); tmpl.SetParameter(2, Log_RecordReportsImpl.ToText_Exception(err_Excp),log_Reports); this.Owner_MemoryApplication.CreateErrorReport( "Er:1;", tmpl, log_Reports ); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_Exception: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー203!", log_Method); StringBuilder s = new StringBuilder(); s.Append("『ツール設定ファイル』(tool config)読み取り中に、何らかのエラーが発生しました。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("もしかして?: XMLのencoding指定が間違っている?この読取プログラムの期待するエンコードでないかも?"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); // // 例外メッセージ s.Append(r.Message_SException(err_Excp)); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return; }
//──────────────────────────────────────── /// <summary> /// ファイル読み込み。 /// </summary> /// <param name="ec_Fpath_Aatoolxml"></param> public void LoadFile( Expression_Node_Filepath ec_Fpath_Aatoolxml, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "LoadFile", log_Reports); // Exception err_Excp; string sFpatha_Aatoolxml = ""; if (log_Reports.Successful) { // // 『ツール設定』をクリアー。 // this.Clear(this.Owner_MemoryApplication); sFpatha_Aatoolxml = ec_Fpath_Aatoolxml.Execute4_OnExpressionString( EnumHitcount.Unconstraint, log_Reports );//絶対ファイルパス } if (log_Reports.Successful) { XmlDocument xDoc = new XmlDocument(); try { // 正常時 xDoc.Load(sFpatha_Aatoolxml); // ルート要素を取得 XmlElement xRoot = xDoc.DocumentElement; // スクリプトファイルのバージョンチェック。(バリデーター登録ファイル) ValuesAttr.Test_Codefileversion( xRoot.GetAttribute(PmNames.S_CODEFILE_VERSION.Name_Attribute), log_Reports, new Configurationtree_NodeImpl(sFpatha_Aatoolxml, null), NamesNode.S_CODEFILE_TOOL ); if (log_Reports.Successful) { // デフォルト・エディター名 this.Name_DefaultEditor = xRoot.GetAttribute(PmNames.S_DEFAULT_EDITOR.Name_Attribute); // エディター要素を列挙 System.Xml.XmlNodeList xNl_Editor = xRoot.GetElementsByTagName(NamesNode.S_EDITOR); foreach (XmlNode x_EditorNode in xNl_Editor) { if (XmlNodeType.Element == x_EditorNode.NodeType) { // // エディター要素 // MemoryAatoolxml_Editor aatool_Editor = new MemoryAatoolxml_EditorImpl(this.cur_Configuration); // // エディター要素 // XmlElement xEditor = (XmlElement)x_EditorNode; // ツール設定ファイルに記載されている、エディター名 try { aatool_Editor.Name = xEditor.GetAttribute(PmNames.S_NAME.Name_Attribute); this.Dictionary_Editor.Dictionary_Item.Add(aatool_Editor.Name, aatool_Editor); } catch (ArgumentException ex) { err_Excp = ex; goto gt_Error_DuplicatedEditorName; } // <f-set-var>要素を列挙 System.Xml.XmlNodeList xNl_Fsetvar = xEditor.GetElementsByTagName(NamesNode.S_F_SET_VAR); for (int nIndex_Fsetvar = 0; nIndex_Fsetvar < xNl_Fsetvar.Count; nIndex_Fsetvar++) { XmlNode xNode_Fsetvar = xNl_Fsetvar.Item(nIndex_Fsetvar); if (XmlNodeType.Element == xNode_Fsetvar.NodeType) { //<f-set-var>要素 Configurationtree_Node cf_Fsetvar = new Configurationtree_NodeImpl(NamesNode.S_F_SET_VAR, ec_Fpath_Aatoolxml.Cur_Configuration); //<f-set-var>要素 XmlElement xFsetvar = (XmlElement)xNode_Fsetvar; string sNamevar = xFsetvar.GetAttribute(PmNames.S_NAME_VAR.Name_Attribute); string sFolder = xFsetvar.GetAttribute(PmNames.S_FOLDER.Name_Attribute); string sValue = xFsetvar.GetAttribute(PmNames.S_VALUE.Name_Attribute); string sDescription = xFsetvar.GetAttribute(PmNames.S_DESCRIPTION.Name_Attribute); cf_Fsetvar.Dictionary_Attribute.Set(PmNames.S_NAME_VAR.Name_Pm, sNamevar, log_Reports); cf_Fsetvar.Dictionary_Attribute.Set(PmNames.S_FOLDER.Name_Pm, sFolder, log_Reports); cf_Fsetvar.Dictionary_Attribute.Set(PmNames.S_VALUE.Name_Pm, sValue, log_Reports); cf_Fsetvar.Dictionary_Attribute.Set(PmNames.S_DESCRIPTION.Name_Pm, sDescription, log_Reports); aatool_Editor.Dictionary_Fsetvar_Configurationtree.List_Child.Add(cf_Fsetvar, log_Reports); } } } } } } catch (System.IO.FileNotFoundException ex) { err_Excp = ex; goto gt_Error_NothingFile; } catch (System.Exception ex) { err_Excp = ex; goto gt_Error_Exception; } } if (log_Reports.Successful) { this.cur_Configuration = ec_Fpath_Aatoolxml.Cur_Configuration; } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_DuplicatedEditorName: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー204!", log_Method); StringBuilder s = new StringBuilder(); s.Append("『ツール設定ファイル』(tool config)読み取り中に、何らかのエラーが発生しました。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("もしかして?: <" + NamesNode.S_EDITOR + ">要素の" + PmNames.S_NAME.Name_Attribute + "属性が重複している?"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); // 例外メッセージ s.Append(r.Message_SException(err_Excp)); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_NothingFile: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, ValuesAttr.S_FPATHR_AATOOLXML, log_Reports); tmpl.SetParameter(2, Log_RecordReportsImpl.ToText_Exception(err_Excp), log_Reports); this.Owner_MemoryApplication.CreateErrorReport("Er:1;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_Exception: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー203!", log_Method); StringBuilder s = new StringBuilder(); s.Append("『ツール設定ファイル』(tool config)読み取り中に、何らかのエラーが発生しました。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("もしかして?: XMLのencoding指定が間違っている?この読取プログラムの期待するエンコードでないかも?"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); // // 例外メッセージ s.Append(r.Message_SException(err_Excp)); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return; }