//──────────────────────────────────────── #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); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// Exe_2ActionImpl#SToFc で使用。 /// </summary> /// <param name="s_Action"></param> /// <param name="bRequired"></param> /// <param name="log_Reports"></param> /// <returns></returns> public Expression_Node_Function Translate( Configurationtree_Node action_Conf, bool bRequired, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Functions.Name_Library, this, "Translate", log_Reports); // // string sName_Fnc; if (action_Conf.Dictionary_Attribute.ContainsKey(PmNames.S_NAME.Name_Pm)) { action_Conf.Dictionary_Attribute.TryGetValue(PmNames.S_NAME, out sName_Fnc, true, log_Reports); } else { sName_Fnc = "<エラー:" + log_Method.Fullname + ">"; } Expression_Node_Function expr_Func = Collection_Function.NewFunction2(sName_Fnc, null, action_Conf, this.Owner_MemoryApplication, log_Reports); if (log_Reports.Successful) { if (null != expr_Func) { Log_TextIndented_ConfigurationtreeToExpressionImpl pg_ParsingLog = new Log_TextIndented_ConfigurationtreeToExpressionImpl(); pg_ParsingLog.BEnabled = false; expr_Func = ((Expression_Node_FunctionAbstract)expr_Func).Functiontranslatoritem.Translate( sName_Fnc, action_Conf,//これは生成時に指定できない? pg_ParsingLog, this.Owner_MemoryApplication, log_Reports ); if (Log_ReportsImpl.BDebugmode_Static && pg_ParsingLog.BEnabled) { log_Method.WriteInfo_ToConsole(" pg_ParsingLog=" + Environment.NewLine + pg_ParsingLog.ToString()); } } } goto gt_EndMethod; // gt_EndMethod: log_Method.EndMethod(log_Reports); return(expr_Func); }
//──────────────────────────────────────── /// <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); }