Пример #1
0
        private void HandleFile(string folder1, string folder2, Dictionary <string, CompareMode> specialFiles, Dictionary <string, Comparence> comparence, FileInfo file, bool inReference, bool ignoreSame = true)
        {
            if (comparence.ContainsKey(file.Name))
            {
                return;
            }

            var cd = new Comparence
            {
                Name          = file.Name,
                File1FullPath = file.FullName,
                Result        = CompareResult.DoesNotExist,
                InReference   = inReference
            };

            var file2FullName = cd.File1FullPath.Replace(folder1, folder2);

            if (File.Exists(file2FullName))
            {
                cd.File2FullPath = file2FullName;

                string contentMarker = null;

                if (specialFiles != null && specialFiles.Count > 0)
                {
                    CompareMode specialFileMode;

                    if (specialFiles.TryGetValue(file.Name, out specialFileMode))
                    {
                        if (specialFileMode == CompareMode.MarkedContent)
                        {
                            contentMarker = Constansts.CONTENT_MARKER;
                        }
                        else
                        {
                            cd.Result = CompareResult.TheSame;

                            return;
                        }
                    }
                }

                cd.Result = CompareResult.HasContentDifferences;

                cd.Difference = AnyDifference(cd.File1FullPath, cd.File2FullPath, contentMarker);

                if (cd.Difference == null)
                {
                    if (ignoreSame)
                    {
                        return;
                    }

                    cd.Result = CompareResult.TheSame;
                }
            }

            comparence.Add(file.Name, cd);
        }
Пример #2
0
        private static void HandleFile(string folder1, string folder2, Dictionary <string, CompareMode> specialFiles, Dictionary <string, Comparence> comparence, FileInfo file, bool inReference)
        {
            if (comparence.ContainsKey(file.Name))
            {
                return;
            }

            var cd = new Comparence
            {
                Name          = file.Name,
                File1FullPath = file.FullName,
                Result        = CompareResult.DoesNotExist,
                InReference   = inReference
            };

            var file2FullName = cd.File1FullPath.Replace(folder1, folder2);

            if (File.Exists(file2FullName))
            {
                cd.File2FullPath = file2FullName;

                if (specialFiles != null)
                {
                    CompareMode specialFileMode;
                    if (specialFiles.TryGetValue(file.Name, out specialFileMode))
                    {
                        cd.Result = CompareResult.TheSame;
                        return;
                    }
                }

                cd.Result = CompareResult.HasContentDifferences;

                cd.Difference = AnyDifference(cd.File1FullPath, cd.File2FullPath);;

                if (cd.Difference == null)
                {
                    cd.Result = CompareResult.TheSame;
                }
            }

            comparence.Add(file.Name, cd);
        }
Пример #3
0
        private static void HandleFile(string folder1, string folder2, Dictionary<string, CompareMode> specialFiles, Dictionary<string, Comparence> comparence, FileInfo file, bool inReference, bool ignoreSame = true)
        {
            if (comparence.ContainsKey(file.Name))
            {
                return;
            }

            var cd = new Comparence
            {
                Name = file.Name,
                File1FullPath = file.FullName,
                Result = CompareResult.DoesNotExist,
                InReference = inReference
            };

            var file2FullName = cd.File1FullPath.Replace(folder1, folder2);
            if (File.Exists(file2FullName))
            {
                cd.File2FullPath = file2FullName;

                if (specialFiles != null)
                {
                    CompareMode specialFileMode;

                    if (specialFiles.TryGetValue(file.Name, out specialFileMode))
                    {
                        cd.Result = CompareResult.TheSame;

                        return;
                    }
                }

                cd.Result = CompareResult.HasContentDifferences;

                cd.Difference = AnyDifference(cd.File1FullPath, cd.File2FullPath);
                ;

                if (cd.Difference == null)
                {
                    if (ignoreSame)
                    {
                        return;
                    }

                    cd.Result = CompareResult.TheSame;
                }
            }

            comparence.Add(file.Name, cd);
        }