Ejemplo n.º 1
0
        /// <summary>単一行の各文字を比較します</summary>
        /// <param name="textA">元テキスト</param>
        /// <param name="textB">変更テキスト</param>
        /// <param name="option">オプション指定</param>
        /// <returns>比較結果</returns>
        public static DiffResult[] DiffChar(string textA, string textB, DiffOption option)
        {
            if (string.IsNullOrEmpty(textA) || string.IsNullOrEmpty(textB))
            {
                return(StringNullOrEmpty(textA, textB));
            }

            FastDiff diff = new FastDiff();

            if (textA.Length <= textB.Length)
            {
                diff.SplitChar(textA, textB, option);
            }
            else
            {
                diff.isSwap = true;
                diff.SplitChar(textB, textA, option);
            }

            diff.isSame = delegate(int posA, int posB)
            {
                return(diff.dataA[posA] == diff.dataB[posB]);
            };

            return(diff.DetectDiff());
        }
Ejemplo n.º 2
0
        /// <summary>複数行の文字列を行単位で比較します</summary>
        /// <param name="textA">元テキスト</param>
        /// <param name="textB">変更テキスト</param>
        /// <param name="option">オプション指定</param>
        /// <returns>比較結果</returns>
        public static DiffResult[] Diff(string textA, string textB, DiffOption option)
        {
            if (string.IsNullOrEmpty(textA) || string.IsNullOrEmpty(textB))
            {
                return(StringNullOrEmpty(textA, textB));
            }

            FastDiff diff = new FastDiff();

            return(diff.DiffCore(textA, textB, option));
        }