Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="leftElm"></param>
        /// <param name="rightElm"></param>
        /// <param name="outputDetailFileFlg"></param>
        /// <returns></returns>
        public static ElementVO getMergedElement(ElementVO leftElm, ElementVO rightElm)
        {
            ElementDiffer differ = new ElementDiffer();

            differ.skipAttributeNoteFlg   = false;
            differ.skipElementTaggedValue = false;
            differ.skipElementTPosFlg     = true;
            differ.skipAttributeNoteFlg   = false;
            differ.skipAttributePosFlg    = false;
            differ.skipMethodNoteFlg      = false;
            differ.skipMethodPosFlg       = false;

            return(differ.getDisagreedElement(leftElm, rightElm));
        }
        /// <summary>
        /// パッケージが保持する要素リストの比較
        /// </summary>
        /// <param name="outPkg"></param>
        /// <param name="lCnt"></param>
        /// <param name="rCnt"></param>
        /// <param name="leftPkg"></param>
        /// <param name="rightPkg"></param>
        void getAgreedPackageContents(PackageVO outPkg, List <ElementVO> leftElements, List <ElementVO> rightElements)
        {
            Int16 lCnt, rCnt;

            ElementDiffer differ = new ElementDiffer();

            differ.skipAttributeNoteFlg   = this.skipAttributeNoteFlg;
            differ.skipElementTaggedValue = this.skipElementTaggedValue;
            differ.skipElementTPosFlg     = this.skipElementTPosFlg;
            differ.skipAttributeNoteFlg   = this.skipAttributeNoteFlg;
            differ.skipAttributePosFlg    = this.skipAttributePosFlg;
            differ.skipMethodNoteFlg      = this.skipMethodNoteFlg;
            differ.skipMethodPosFlg       = this.skipMethodPosFlg;


            // GUIDで一致するものがあった場合:

            // GUIDで一致するものが無かった場合: L > R なら Rの追加、 R < L なら Lの削除 とみなす
            ElementVO        lElm, rElm, oElm;
            List <ElementVO> outElements = new List <ElementVO>();

            for (lCnt = 0, rCnt = 0; lCnt < leftElements.Count && rCnt < rightElements.Count;)
            {
                // 左側が最終の要素に達した場合
                if (lCnt >= leftElements.Count)
                {
                    // 右側の要素が追加されたものとして出力パッケージリストに追加
                    oElm         = rightElements[rCnt];
                    oElm.changed = 'C';
                    outElements.Add(oElm);
                    rCnt++;
                    continue;
                }

                // 右側が最終の要素に達した場合
                if (rCnt >= rightElements.Count)
                {
                    // 左側の要素が削除されたものとして出力パッケージリストに追加
                    oElm         = leftElements[lCnt];
                    oElm.changed = 'D';
                    outElements.Add(oElm);
                    lCnt++;
                    continue;
                }

                lElm = leftElements[lCnt];
                rElm = rightElements[rCnt];


                if (compareElementGuid(lElm, rElm) == 0)
                {
                    // 要素の内容を比較
                    oElm = differ.getDisagreedElement(lElm, rElm);
                    if (oElm != null)
                    {
                        oElm.changed = 'U';
                        outElements.Add(oElm);
                    }
                    lCnt++;
                    rCnt++;
                }
                else
                {
                    if (compareElementGuid(lElm, rElm) > 0)
                    {
                        rElm.changed = 'C';
                        outElements.Add(rElm);
                        rCnt++;
                    }
                    else
                    {
                        lElm.changed = 'D';
                        outElements.Add(lElm);
                        lCnt++;
                    }
                }
            }
            outPkg.elements = outElements;
        }