コード例 #1
0
        //────────────────────────────────────────

        /// <summary>
        /// 未実装の場合。
        /// </summary>
        /// <param name="parent_Conf"></param>
        /// <param name="log_Reports"></param>
        static public void NoImpl_Expression_AddChild(
            Conf_String parent_Conf,
            Log_Reports log_Reports
            )
        {
            //
            // エラー。

            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Syntax.Name_Library, "Util_Expression_Node_String", "NoImpl_Expression_AddChild", log_Reports);

            //
            //
            //
            //

            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー361!", log_Method);

                StringBuilder sb = new StringBuilder();

                sb.Append("Expression_AddChild メソッドは、未実装です。");
                sb.Append(Environment.NewLine);
                sb.Append(Environment.NewLine);

                // ヒント
                sb.Append(r.Message_Conf(parent_Conf));

                r.Message = sb.ToString();
                log_Reports.EndCreateReport();
            }

            //
            //
            //
            //
            log_Method.EndMethod(log_Reports);
        }
コード例 #2
0
        //────────────────────────────────────────

        public List <Expr_String> GetChildElements(
            EnumHitcount request,
            Log_Reports log_Reports
            )
        {
            //
            // エラー。

            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "GetChildElements", log_Reports);

            //
            //
            //
            //

            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);

                r.SetTitle("▲エラー101!", log_Method);

                Log_TextIndented t = new Log_TextIndentedImpl();
                t.Append("このメソッド " + log_Method.Fullname + " は使わないでください。");

                // ヒント
                t.Append(r.Message_Conf(this.Conf));

                r.Message = t.ToString();

                log_Reports.EndCreateReport();
            }
            //
            //
            log_Method.EndMethod(log_Reports);
            return(null);
        }
コード例 #3
0
        //────────────────────────────────────────

        /// <summary>
        /// 子要素を追加します。
        /// </summary>
        /// <param name="items"></param>
        /// <param name="request"></param>
        /// <param name="log_Reports"></param>
        public void AddChildElement(
            Expr_String eChild,
            Log_Reports log_Reports
            )
        {
            //
            // エラー。

            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "AddChildElement", log_Reports);

            //
            //
            //
            //

            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);

                r.SetTitle("▲エラー201!", log_Method);

                Log_TextIndented t = new Log_TextIndentedImpl();
                t.Append("このメソッド " + log_Method.Fullname + " は使わないでください。");

                // ヒント
                t.Append(r.Message_Conf(this.Conf));

                r.Message = t.ToString();

                log_Reports.EndCreateReport();
            }

            //
            //
            log_Method.EndMethod(log_Reports);
        }
コード例 #4
0
        //────────────────────────────────────────
        #endregion



        #region アクション
        //────────────────────────────────────────

        /// <summary>
        /// attr系要素の追加。
        ///
        /// 既に追加されている要素は、追加できない。
        /// </summary>
        public void Add(
            string key,
            string value,
            Conf_String cValue,
            bool isRequired,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "Add", log_Reports);

            //
            //

            if (!this.map.ContainsKey(key))
            {
                this.map.Add(key, value);
            }
            else
            {
                if (isRequired)
                {
                    // エラー
                    goto gt_Error_Duplicate;
                }
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
gt_Error_Duplicate:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー345!", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();

                s.Append("要素<");
                s.Append(this.owner.Name);
                s.Append(">に、同じ名前の属性が重複していました。");
                s.Newline();

                s.Append("入れようとした要素の名前=[");
                s.Append(key);
                s.Append("]");
                s.Newline();

                // ヒント
                s.Append(r.Message_Conf(cValue));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
コード例 #5
0
        /// <summary>
        /// 空白は、無いのと同じに扱う。
        /// </summary>
        /// <param name="name"></param>
        /// <param name="result"></param>
        /// <param name="isRequired"></param>
        /// <param name="log_Reports"></param>
        /// <returns></returns>
        public bool TryGetValue(
            PmName name,//Pmオブジェクトにしたい。
            out string result,
            bool isRequired,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "TryGetValue", log_Reports);
            //


            bool bHit = this.map.TryGetValue(name.Pm, out result);

            if (!bHit || "" == result)
            {
                if (isRequired)
                {
                    goto gt_Error_NoHit;
                }
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
gt_Error_NoHit:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("Er:004;", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();


                s.Append("name=\"");
                s.Append(name.Plain);
                s.Append("\" 属性か、または <arg name=\"");
                s.Append(name.Pm);
                s.Append("\" ~> 要素のどちらかが必要でしたが、違う方を書いたか、記述されていないか、空文字列でした。");
                s.Newline();
                s.Newline();

                if (null != this.owner)
                {
                    //ヒント
                    s.Append(r.Message_Conf(this.owner));
                }
                else
                {
                    s.Append("どの要素かは不明。");
                    s.Newline();
                }

                // ヒント

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(bHit);
        }
コード例 #6
0
        //────────────────────────────────────────

        /// <summary>
        /// 「フィールド名=値」という条件1つで検索。該当するレコード0~N件を返す。
        /// </summary>
        /// <param name="dst_Row"></param>
        /// <param name="name_KeyField"></param>
        /// <param name="value_Expected"></param>
        /// <param name="isRequired_ExpectedValue"></param>
        /// <param name="fielddefinition_Key"></param>
        /// <param name="dataTable"></param>
        /// <param name="s_ParentNode_query"></param>
        /// <param name="log_Reports"></param>
        public void Select(
            out List <DataRow> out_List_DstRow,
            string name_KeyField,
            string value_Expected,
            bool isRequired_ExpectedValue,
            Fielddef fielddefinition_Key,
            DataTable dataTable,
            Conf_String parent_Query,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Table.Name_Library, this, "Select", log_Reports);

            //
            //
            //
            //

            out_List_DstRow = new List <DataRow>();

            Judge_FieldBoolImpl   judgeB = new Judge_FieldBoolImpl();
            Judge_FieldIntImpl    judgeI = new Judge_FieldIntImpl();
            Judge_FieldStringImpl judgeS = new Judge_FieldStringImpl();


            foreach (DataRow row in dataTable.Rows)
            {
                bool bJudge;

                switch (fielddefinition_Key.Type_Field)
                {
                case EnumTypeFielddef.String:
                {
                    // string型フィールドなら
                    judgeS.Judge(
                        out bJudge,
                        name_KeyField,
                        value_Expected,
                        isRequired_ExpectedValue,
                        row,
                        parent_Query,
                        log_Reports
                        );
                }
                break;

                case EnumTypeFielddef.Int:
                {
                    // int型フィールドなら
                    judgeI.Judge(
                        out bJudge,
                        name_KeyField,
                        value_Expected,
                        isRequired_ExpectedValue,
                        row,
                        parent_Query,
                        log_Reports
                        );
                }
                break;

                case EnumTypeFielddef.Bool:
                {
                    // bool型フィールドなら
                    judgeB.Judge(
                        out bJudge,
                        name_KeyField,
                        value_Expected,
                        isRequired_ExpectedValue,
                        row,
                        parent_Query,
                        log_Reports
                        );
                }
                break;

                default:
                {
                    // エラー。
                    goto gt_Error_UndefinedClass;
                }
                break;
                }

                if (!log_Reports.Successful)
                {
                    // 既エラー。
                    goto gt_EndMethod;
                }

                if (bJudge)
                {
                    out_List_DstRow.Add(row);
                }
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
gt_Error_UndefinedClass:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー899", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();

                s.AppendI(0, "<NFuncCellUpdaterImplクラス>");
                s.Append(Environment.NewLine);

                s.AppendI(1, "予期しない型です。");
                s.Append(Environment.NewLine);

                s.AppendI(1, "keyFldDefinition.Type=[");
                s.Append(fielddefinition_Key.ToString_Type());
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                // ヒント
                s.AppendI(1, r.Message_Conf(parent_Query));

                s.AppendI(0, "</NFuncCellUpdaterImplクラス>");

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
コード例 #7
0
        //────────────────────────────────────────
        #endregion



        #region アクション
        //────────────────────────────────────────

        /// <summary>
        /// インスタンスを作ります。
        /// </summary>
        /// <param name="out_recCond"></param>
        /// <param name="logic"></param>
        /// <param name="sField"></param>
        /// <param name="s_ParentNode"></param>
        /// <returns></returns>
        public static bool TryBuild(
            out Recordcondition out_RecCond,
            EnumLogic enumLogic,
            string sField,
            Conf_String parent_Conf,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0);

            log_Method.BeginMethod(Info_Table.Name_Library, "RecCondImpl", "TryBuild", log_Reports);

            bool bSuccessful;

            sField = sField.Trim();

            if (EnumLogic.None == enumLogic && "" != sField)
            {
                // 条件式

                RecordconditionImpl rc = new RecordconditionImpl(parent_Conf);
                rc.sField   = sField;
                out_RecCond = rc;
                bSuccessful = true;
            }
            else if (EnumLogic.None != enumLogic && "" == sField)
            {
                // グループ

                RecordconditionImpl rc = new RecordconditionImpl(parent_Conf);
                rc.sField    = "(▲グループにフィールド属性無し103![" + enumLogic + "])";
                rc.enumLogic = enumLogic;
                out_RecCond  = rc;
                bSuccessful  = true;
            }
            else
            {
                out_RecCond = null;
                bSuccessful = false;
                goto gt_Error_Attribute;
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
gt_Error_Attribute:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー101!", log_Method);

                StringBuilder s = new StringBuilder();
                s.Append("<rec-cond>インスタンスを作成する引数にエラー。");
                s.Append(Environment.NewLine);
                s.Append("logic=[");
                s.Append(enumLogic);
                s.Append("] sField=[");
                s.Append(sField);
                s.Append("]");
                s.Append(Environment.NewLine);

                s.Append(r.Message_Conf(parent_Conf));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();

                //throw new Exception(s.ToString());
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(bSuccessful);
        }
コード例 #8
0
        //────────────────────────────────────────
        #endregion



        #region アクション
        //────────────────────────────────────────

        /// <summary>
        /// パーサーのハブ。
        ///
        /// </summary>
        /// <param name="request_ReadsTable">テーブルに付けたい名前や、ファイルパスの要求。</param>
        /// <param name="tableFormat_puts">テーブルの行列が逆になっているなどの、設定。</param>
        /// <param name="isRequired">テーブルが無かった場合、エラーとするなら真。</param>
        /// <param name="out_sErrorMsg"></param>
        /// <returns></returns>
        public Table_Humaninput Read(
            Request_ReadsTable request_ReadsTable,
            Format_Table tableFormat_puts,
            bool isRequired,
            Encoding encodingCsv,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl();

            log_Method.BeginMethod(Info_Table.Name_Library, this, "Read", log_Reports);


            // 読み取ったテーブル
            Table_Humaninput xTable;

            //絶対ファイルパス
            string csvAbs = request_ReadsTable.Expression_Filepath.Lv4Execute_OnImplement(
                EnumHitcount.Unconstraint, log_Reports);

            if (!log_Reports.Successful)
            {
                // 既エラー。
                xTable = null;
                goto gt_EndMethod;
            }

            // CSVテキスト
            string    contents;
            Exception error_Excp;

            if (CsvTo_TableImpl.S_WRITE_ONLY != request_ReadsTable.Use)
            {
                // 書き出し専用でなければ。
                // ファイル読取を実行します。

                try
                {
                    if (!System.IO.File.Exists(csvAbs))
                    {
                        // ファイルが存在しない場合。
                        xTable = null;
                        goto gt_Error_NotExistsFile;
                    }

                    // TODO:IOException 別スレッドで開いているときなど。

                    contents = System.IO.File.ReadAllText(csvAbs, encodingCsv);
                    //log_Method.WriteDebug_ToConsole(string_Csv);
                }
                catch (System.IO.IOException e)
                {
                    // エラー処理。
                    xTable     = null;
                    contents   = "";
                    error_Excp = e;
                    goto gt_Error_FileOpen;
                }
                catch (Exception e)
                {
                    // エラー処理。
                    xTable     = null;
                    contents   = "";
                    error_Excp = e;
                    goto gt_Error_Exception;
                }
            }
            else
            {
                contents = "";
            }

            xTable = this.Read(
                contents,
                request_ReadsTable,
                tableFormat_puts,
                log_Reports
                );
            if (!log_Reports.Successful)
            {
                // 既エラー。
                goto gt_EndMethod;
            }

            // NOフィールドの値を 0からの連番に振りなおします。
            xTable.RenumberingNoField();

            if (isRequired && null == xTable)
            {
                goto gt_Error_NullTable;
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
gt_Error_FileOpen:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("Er:201;", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("ファイルの読取りに失敗しました。");
                s.Newline();
                s.Newline();

                s.Append(" ファイル=[");
                s.Append(csvAbs);
                s.Append("]");
                s.Newline();
                s.Newline();

                s.Append("もしかして?");
                s.Newline();

                s.Append(" ・ファイルの有無、ファイル名、ファイル パスを確認してください。");
                s.Newline();
                s.Append(" ・別アプリケーションで ファイルを開いていれば、閉じてください。");
                s.Newline();
                s.Newline();

                //
                // ヒント
                request_ReadsTable.Expression_Filepath.Conf.ToText_Locationbreadcrumbs(s);
                s.Append(error_Excp.Message);

                r.Message = s.ToString();

                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
gt_Error_NotExistsFile:
            if (log_Reports.CanCreateReport)
            {
                if ("" == request_ReadsTable.Expression_Filepath.Directory_Base)
                {
                    Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                    r.SetTitle("Er:202;", log_Method);

                    Log_TextIndented s = new Log_TextIndentedImpl();
                    s.Append("指定されたファイルはありませんでした。CSVファイルを読み込もうとしたとき。");
                    s.Newline();
                    s.Newline();

                    s.AppendI(1, "指定されたファイルパス=[");
                    s.Append(csvAbs);
                    s.Append("]");
                    s.Newline();

                    {
                        s.AppendI(1, "ベース・ディレクトリは指定されていません。");
                        s.Newline();
                        s.AppendI(2, "もし相対パスが指定されていた場合、実行した.exeファイルからの相対パスとします。");
                        s.Newline();
                        s.Newline();
                    }

                    s.Append(" ヒント:ファイルの有無、ファイル名、ファイル パスを確認してください。");
                    s.Newline();

                    // ヒント
                    s.Append(r.Message_Conf(
                                 request_ReadsTable.Expression_Filepath.Conf));
                    r.Message = s.ToString();
                }
                else
                {
                    Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                    r.SetTitle("▲エラー235!", log_Method);

                    Log_TextIndented s = new Log_TextIndentedImpl();
                    s.Append("指定されたファイルはありませんでした。CSVファイルを読み込もうとしたとき。");
                    s.Newline();
                    s.Newline();

                    s.AppendI(1, "指定されたファイルパス=[");
                    s.Append(csvAbs);
                    s.Append("]");
                    s.Newline();

                    {
                        s.AppendI(1, "指定されたベース・ディレクトリ=[");
                        s.Append(request_ReadsTable.Expression_Filepath.Directory_Base);
                        s.Append("]");
                        s.Newline();
                        s.Newline();
                    }

                    s.Append(" ヒント:ファイルの有無、ファイル名、ファイル パスを確認してください。");
                    s.Newline();

                    // ヒント
                    s.Append(r.Message_Conf(
                                 request_ReadsTable.Expression_Filepath.Conf));
                    r.Message = s.ToString();
                }


                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
gt_Error_Exception:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー104!", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("▲エラー4030!(" + Info_Table.Name_Library + ")");
                s.Newline();
                s.Append("CSV読み取り中にエラーが発生しました。");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);
                s.Append("指定CSVファイル=[");
                s.Append(csvAbs);
                s.Append("]");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                //
                // ヒント
                request_ReadsTable.Expression_Filepath.Conf.ToText_Locationbreadcrumbs(s);


                s.Append("エラーの種類:");
                s.Append(error_Excp.GetType().Name);
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);
                s.Append("エラーメッセージ:");
                s.Append(error_Excp.Message);

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
gt_Error_NullTable:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー105!", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("▲エラー131!");
                s.Newline();
                s.Append("[");
                s.Append(request_ReadsTable.Name_PutToTable);
                s.Append("]テーブルがありませんでした。");
                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);
            return(xTable);
        }
コード例 #9
0
        //────────────────────────────────────────

        /// <summary>
        /// 要素名を指定して、子ノードを取得したい。
        /// </summary>
        /// <param name="name"></param>
        /// <param name="isRequired">偽を指定した時は、要素数0のリストを返す。</param>
        /// <param name="log_Reports"></param>
        /// <returns></returns>
        public List <Conf_String> GetChildrenByName(string name, bool isRequired, Log_Reports log_Reports)
        {
            Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static);

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "GetChildrenByNodename", log_Reports);
            //
            //
            List <Conf_String> result = new List <Conf_String>();

            if (log_Reports.Successful)
            {
                this.childNodes.ForEach(delegate(Conf_String child_Conf, ref bool bBreak)
                {
                    if (name == child_Conf.Name)
                    {
                        // ノード名が一致
                        result.Add(child_Conf);
                    }
                    else
                    {
                        // ノード名が一致しないとき
                    }
                });
            }
            else
            {
                // 既にエラーが出ているとき
                goto gt_EndMethod;
            }

            if (result.Count < 1 && isRequired)
            {
                if (isRequired)
                {
                    goto gt_Error_EmptyHitChild;
                }
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
gt_Error_EmptyHitChild:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー502!", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("該当した子要素がありませんでした。");
                s.Newline();


                s.Append("指定ノード名[");
                s.Append(name);
                s.Append("]");
                s.Newline();

                // ヒント
                s.Append(r.Message_Conf(this));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(result);
        }
コード例 #10
0
        /// <summary>
        /// 直近の1件の子要素を返します。
        /// 該当がなければヌルを返します。
        /// </summary>
        /// <param name="projectName"></param>
        /// <param name="isRequired">該当がない場合にエラー扱いにするなら真</param>
        /// <returns></returns>
        public Conf_String GetFirstChildByAttr(
            PmName expectedName,
            string sExpectedValue,
            bool isRequired,
            Log_Reports log_Reports)
        {
            Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static);

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "GetFirstChildByAttr", log_Reports);
            //
            //

            Conf_String cResult = null;

            if (log_Reports.Successful)
            {
                bool isHit = false;

                this.ChildNodes.ForEach(delegate(Conf_String item2, ref bool isBreak2)
                {
                    string value;
                    item2.Attributes.TryGetValue(expectedName, out value, false, log_Reports);

                    if (value == sExpectedValue)
                    {
                        isHit    = true;
                        cResult  = item2;
                        isBreak2 = true;
                    }
                });

                if (!isHit)
                {
                    cResult = null;

                    if (isRequired)
                    {
                        // エラーとして扱います。
                        goto gt_Error_NotFound;
                    }
                }
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
gt_Error_NotFound:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー002!", log_Method);

                StringBuilder s = new StringBuilder();
                s.Append("指定された要素は存在しませんでした。");
                s.Append(Environment.NewLine);
                s.Append(Environment.NewLine);

                s.Append("指定属性=[");
                s.Append(expectedName.Pm);
                s.Append("]");
                s.Append(Environment.NewLine);

                s.Append("指定値=[");
                s.Append(sExpectedValue);
                s.Append("]");
                s.Append(Environment.NewLine);

                //s.Append("┌──────────┐");
                //this.ChildNodes.ForEach(delegate(Conf_String item2, ref bool isBreak2)
                //{
                //    string value;
                //    item2.Attributes.TryGetValue(expectedName, out value, false, log_Reports);

                //    if (value == sExpectedValue)
                //    {
                //        isHit = true;
                //        cResult = item2;
                //        isBreak2 = true;
                //    }
                //});
                //s.Append("└──────────┘");

                // ヒント
                s.Append(r.Message_Conf(this));

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(cResult);
        }
コード例 #11
0
        //────────────────────────────────────────

        /// <summary>
        /// ノード名を指定して、直近の親ノードを取得したい。
        /// </summary>
        /// <param name="name"></param>
        /// <param name="isRequired">偽を指定した時は、不一致の時ヌルを返す。</param>
        /// <param name="log_Reports"></param>
        /// <returns></returns>
        public virtual Conf_String GetParentByName(
            string name, bool isRequired, Log_Reports log_Reports)
        {
            Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static);

            log_Method.BeginMethod(Info_Syntax.Name_Library, this, "GetParentByNodename", log_Reports);
            //
            //
            Conf_String result;

            Conf_String err_cParent;

            if (log_Reports.Successful)
            {
                if (null != this.Parent)
                {
                    // 親要素があるとき

                    if (name == this.Parent.Name)
                    {
                        // ノード名が一致
                        result = this.Parent;
                    }
                    else
                    {
                        // ノード名が一致しないとき
                        result = this.Parent.GetParentByName(name, isRequired, log_Reports);
                    }
                }
                else
                {
                    // 親要素がないとき

                    result      = null;
                    err_cParent = null;
                    goto gt_Error_NotFoundParent;
                }
            }
            else
            {
                // 既にエラーが出ているとき

                result = null;
            }

            if (!(result is Conf_String))
            {
                //エラー
                goto gt_Error_AnotherClass;
            }

            goto gt_EndMethod;
            //
            //
            #region 異常系
            //────────────────────────────────────────
gt_Error_NotFoundParent:
            if (log_Reports.CanCreateReport)
            {
                if (isRequired)
                {
                    Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                    r.SetTitle("▲エラー501!", log_Method);

                    Log_TextIndented s = new Log_TextIndentedImpl();
                    s.Append("親要素の取得に失敗しました。");
                    s.Newline();


                    s.Append("指定ノード名[");
                    s.Append(name);
                    s.Append("]");
                    s.Newline();

                    s.Append("親要素はヌルです。");
                    s.Newline();

                    if (null != err_cParent)
                    {
                        s.Append("親要素ノード名[");
                        s.Append(err_cParent.Name);
                        s.Append("]");
                        s.Newline();
                    }

                    // ヒント
                    s.Append(r.Message_Conf(this));

                    r.Message = s.ToString();
                    log_Reports.EndCreateReport();
                }
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
gt_Error_AnotherClass:
            if (log_Reports.CanCreateReport)
            {
                if (isRequired)
                {
                    Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                    r.SetTitle("▲エラー502!", log_Method);

                    Log_TextIndented s = new Log_TextIndentedImpl();
                    s.Append("(内部プログラム・エラー)取得した親要素は、指定のクラスとは異なりました。");
                    s.Newline();

                    s.Append("取得した親要素のクラス名[");
                    s.Append(result.GetType().Name);
                    s.Append("]");
                    s.Newline();

                    // ヒント
                    s.Append(r.Message_Conf(this));

                    r.Message = s.ToString();
                    log_Reports.EndCreateReport();
                }
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            return(result);
        }