//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// 妥当性判定のグローバル設定ファイルの読取り。 /// </summary> /// <param name="sFpatha">絶対ファイルパス</param> /// <param name="log_Reports"></param> public void LoadFile( string sFpatha, 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); // // this.xToConfigurationtree_V.XmlToConfigurationtree( sFpatha, owner_MemoryApplication, log_Reports ); Log_TextIndented_ConfigurationtreeToExpressionImpl pg_ParsingLog = new Log_TextIndented_ConfigurationtreeToExpressionImpl(); pg_ParsingLog.BEnabled = false; this.givechapterandverseToExpression_V.Translate( owner_MemoryApplication, pg_ParsingLog, log_Reports ); if (log_Method.CanInfo() && pg_ParsingLog.BEnabled) { log_Method.WriteInfo_ToConsole(" d_ParsingLog=" + Environment.NewLine + pg_ParsingLog.ToString()); } // // log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <summary> /// デバッグ出力。 /// </summary> public void WriteDebug_ToConsole() { Log_Method log_Method = new Log_MethodImpl(0); Log_Reports d_Logging_Dammy = new Log_ReportsImpl(log_Method); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "WriteDebug_ToConsole", d_Logging_Dammy); // // if (log_Method.CanInfo()) { log_Method.WriteInfo_ToConsole("要素数=[" + this.dictionaryExpression_Item.Count + "]"); // 項目(キーと値)の列挙 foreach (KeyValuePair <string, Expression_Node_String> kvp in this.dictionaryExpression_Item) { if (null == kvp.Value) { log_Method.WriteInfo_ToConsole(" [" + kvp.Key + "]=空っぽ"); } else { if (kvp.Value is Expression_Node_Filepath) { // ファイルパス型。 // bug: 絶対パスでない場合、空白になるので、SHumanInput で取得することになるはず。 log_Method.WriteInfo_ToConsole(" [" + kvp.Key + "]=P型[" + kvp.Value.Execute4_OnExpressionString(EnumHitcount.Unconstraint, d_Logging_Dammy) + "] / SHumanInput=[" + ((Expression_Node_Filepath)kvp.Value).Humaninput + "]"); } else { log_Method.WriteInfo_ToConsole(" [" + kvp.Key + "]=[" + kvp.Value.Execute4_OnExpressionString(EnumHitcount.Unconstraint, d_Logging_Dammy) + "]"); } } } } // // log_Method.EndMethod(d_Logging_Dammy); d_Logging_Dammy.EndLogging(log_Method); if (!d_Logging_Dammy.Successful) { log_Method.WriteDebug_ToConsole(d_Logging_Dammy.ToText()); } }
//──────────────────────────────────────── /// <summary> /// デバッグ出力。 /// </summary> public void WriteDebug_ToConsole() { Log_Method log_Method = new Log_MethodImpl(0); Log_Reports log_Reports_ThisMethod = new Log_ReportsImpl(log_Method); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "DebugWrite", log_Reports_ThisMethod); // // if (log_Method.CanInfo()) { log_Method.WriteInfo_ToConsole(" ──────────登録関数名一覧"); foreach (string sKey in this.dictionary_Item.Keys) { log_Method.WriteInfo_ToConsole(" key=[" + sKey + "]"); } log_Method.WriteInfo_ToConsole(" ──────────"); } log_Method.EndMethod(log_Reports_ThisMethod); }
//──────────────────────────────────────── /// <summary> /// ファイルパス型変数を登録します。 /// /// todo:文字列、ファイルパスの区別なく登録したい。 /// </summary> /// <param name="sVariableName"></param> /// <param name="e_InitialValue"></param> /// <param name="bDuplicatedIsError">既に追加されているものを、更に追加しようとしたときにエラーにするなら真。</param> /// <param name="log_Reports"></param> public void PutFilepath( string sName_Variable, Expression_Node_Filepath ec_InitialValue, bool bDuplicatedIsError, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "PutFilepath", log_Reports); // // if (this.dictionaryExpression_Item.ContainsKey(sName_Variable)) { if (bDuplicatedIsError) { goto gt_Error_Duplicated; } else { // 上書き string sOldValue = ""; if (log_Method.CanInfo()) { sOldValue = this.dictionaryExpression_Item[sName_Variable].Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); } this.dictionaryExpression_Item[sName_Variable] = ec_InitialValue; if (log_Method.CanInfo()) { log_Method.WriteInfo_ToConsole("変数[" + sName_Variable + "]は既に[" + sOldValue + "]と定義されていましたが、[" + ec_InitialValue.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]で上書きしました。"); } } } else { this.dictionaryExpression_Item.Add(sName_Variable, ec_InitialValue); } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_Duplicated: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー922!", log_Method); r.Message = "変数[" + sName_Variable + "]は既に定義されていますが、さらに定義されました。"; log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <summary> /// 『ユーザー定義関数設定ファイル(Fnc)』を読み取ります。 /// </summary> public void LoadFile( Expression_Node_Filepath filepath_Userfunctionconfig_Expr, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "LoadFile", log_Reports); // // if (log_Method.CanDebug(1)) { log_Method.WriteDebug_ToConsole(" ユーザー定義関数設定ファイルの読み取り。"); } Configurationtree_Node parent_Conf = new Configurationtree_NodeImpl(NamesNode.S_CODEFILE_FUNCTIONS, filepath_Userfunctionconfig_Expr.Cur_Configuration);//Info_OpyopyoImpl.LibraryName + ":" + this.GetType().Name + ".LoadFile_Fnc" Expression_Node_String userfunctionconfig_Expr = new Expression_Node_StringImpl(null, parent_Conf); string filepathabsolute = filepath_Userfunctionconfig_Expr.Execute4_OnExpressionString( EnumHitcount.Unconstraint, log_Reports); if (!log_Reports.Successful) { goto gt_Error_Fpath; } if (!System.IO.File.Exists(filepathabsolute)) { goto gt_Error_File; } XmlDocument xDoc = new XmlDocument(); Exception err_Excp = null; try { xDoc.Load(filepathabsolute); } catch (System.IO.IOException ex) { // // エラー。 err_Excp = ex; goto gt_Error_Doc; } catch (ArgumentException ex) { // // エラー。 err_Excp = ex; goto gt_Error_Doc; } catch (Exception ex) { // // エラー。 err_Excp = ex; goto gt_Error_Doc; } XmlElement xRoot = null; if (log_Reports.Successful) { // ルート要素を取得 xRoot = xDoc.DocumentElement; // スクリプトファイルのバージョンチェック。(関数登録ファイル) ValuesAttr.Test_Codefileversion( xRoot.GetAttribute(PmNames.S_CODEFILE_VERSION.Name_Attribute), log_Reports, new Configurationtree_NodeImpl(filepathabsolute, null), NamesNode.S_CODEFILE_FUNCTIONS ); } string sErrorElementName = ""; if (log_Reports.Successful) { XmlNodeList xTopNL = xRoot.ChildNodes; foreach (XmlNode xTopNode in xTopNL) { if (XmlNodeType.Element == xTopNode.NodeType) { if (NamesNode.S_COMMON_FUNCTION == xTopNode.Name) { XmlElement x_Cur = (XmlElement)xTopNode; string sNameValue = x_Cur.GetAttribute(PmNames.S_NAME.Name_Attribute); if (log_Method.CanDebug(1)) { log_Method.WriteDebug_ToConsole(" ユーザー定義関数の追加を開始:" + sNameValue); } // XToCf XmlToConfigurationtree_C15_Elm xToCf = XmlToConfigurationtree_Collection.GetTranslatorByNodeName(NamesNode.S_COMMON_FUNCTION, log_Reports); xToCf.XmlToConfigurationtree( x_Cur, parent_Conf, this.Owner_MemoryApplication, log_Reports ); Configurationtree_Node s_Cur = null; parent_Conf.List_Child.ForEach(delegate(Configurationtree_Node s_Child, ref bool bBreak) { s_Cur = s_Child; bBreak = true; }); // SToE Expression_Node_FunctionImpl ec_CommonFunction = new Expression_Node_FunctionImpl(userfunctionconfig_Expr, s_Cur, new List <string>()); Log_TextIndented_ConfigurationtreeToExpressionImpl pg_ParsingLog = new Log_TextIndented_ConfigurationtreeToExpressionImpl(); pg_ParsingLog.BEnabled = false; ConfigurationtreeToExpression_AbstractImpl.ParseChild_InAnotherLibrary( s_Cur, ec_CommonFunction, this.Owner_MemoryApplication, pg_ParsingLog, log_Reports ); if (log_Method.CanInfo() && pg_ParsingLog.BEnabled) { log_Method.WriteInfo_ToConsole(" d_ParsingLog=" + Environment.NewLine + pg_ParsingLog.ToString()); } this.Owner_MemoryApplication.MemoryFunctions.AddFunction(sNameValue, ec_CommonFunction, log_Reports); } else { // // エラー。 sErrorElementName = xTopNode.Name; goto gt_Error_UndefinedChild; } } } } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_Fpath: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー101!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("ユーザー定義関数設定ファイルへのパスにエラーがありました。"); s.Newline(); s.Newline(); // ヒント r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_File: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー102!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("ユーザー定義関数設定ファイルがありません。"); s.Newline(); s.Append("file=["); s.Append(filepathabsolute); s.Append("]"); s.Newline(); s.Newline(); // ヒント r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_Doc: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー103!", log_Method); StringBuilder s = new StringBuilder(); s.Append("エラー:" + err_Excp.Message); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append(Log_RecordReportsImpl.ToText_Configuration(filepath_Userfunctionconfig_Expr.Cur_Configuration)); // ヒント r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_UndefinedChild: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー104!", log_Method); StringBuilder s = new StringBuilder(); s.Append("未定義の要素:" + sErrorElementName); s.Append(Environment.NewLine); s.Append(Environment.NewLine); // ヒント r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); }