Example #1
0
 //-i, --ignore-initial=SKIP skip first SKIP bytes of both inputs
 //-i, --ignore-initial=SKIP1:SKIP2 skip first SKIP1 bytes of FILE1 and first SKIP2 bytes of FILE2
 public static int IgnoreInitialBytes(string pathToFile1, string pathToFile2, int skip1, int skip2 = 0)
 {
     DifferenceInfo diff = Compare(out int output, true, pathToFile1, pathToFile2, skip1, skip2, -1)[0];
 public override string PrintMessage()
 {
     return($"{DifferenceInfo.GetDifferenceName()}: there is no difference");
 }
 public override string PrintMessage()
 {
     return($"{DifferenceInfo.GetDifferenceName()}: there are differences at positions: {string.Join(',',DifferenceInfo.Positions.ToArray())}");
 }
 public override string PrintMessage()
 {
     return($"{DifferenceInfo.GetDifferenceName()}: the longer string is '{DifferenceInfo.Longer}' by {DifferenceInfo.Number} characters");
 }
Example #5
0
        private DifferenceInfo GetDiffrenceInfo(Type type, XElement current, XElement previous)
        {
            var property = GetProperty(type, current.Name.LocalName);

            if (property == null)
            {
                return(null);
            }
            if (property.GetCustomAttributes(typeof(SubPropertyIgnoreAttribute), false).Any())
            {
                return(null);
            }
            var displayName      = current.Name.LocalName;
            var displayAttribute = property.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault() as DisplayAttribute;

            if (displayAttribute != null)
            {
                displayName = displayAttribute.Name;
            }

            var result = new DifferenceInfo()
            {
                PropertyName = displayName
            };
            var subPropertyNameAttribute = property.GetCustomAttributes(typeof(SubPropertyNameAttribute), false).FirstOrDefault() as SubPropertyNameAttribute;

            if (subPropertyNameAttribute == null)
            {
                result.Previous = previous == null?String.Empty: previous.Value;
                result.Current  = current == null ? String.Empty : current.Value;
            }
            else
            {
                if (String.IsNullOrEmpty(subPropertyNameAttribute.PropertyName))
                {
                    return(null);
                }
                if (!String.IsNullOrEmpty(subPropertyNameAttribute.TypeName))
                {
                    var values = current.Elements(subPropertyNameAttribute.TypeName).Where(s => s.Element(subPropertyNameAttribute.PropertyName) != null).Select(s => s.Element(subPropertyNameAttribute.PropertyName).Value).ToArray();
                    if (values.Length > 0)
                    {
                        result.Current = String.Join(" ,", values);
                    }
                    values = previous.Elements(subPropertyNameAttribute.TypeName).Where(s => s.Element(subPropertyNameAttribute.PropertyName) != null).Select(s => s.Element(subPropertyNameAttribute.PropertyName).Value).ToArray();
                    if (values.Length > 0)
                    {
                        result.Previous = String.Join(" ,", values);
                    }
                }
                else
                {
                    result.Current = current.Element(subPropertyNameAttribute.PropertyName) == null
                                                ? String.Empty
                                                : current.Element(subPropertyNameAttribute.PropertyName).Value;
                    result.Previous = previous.Element(subPropertyNameAttribute.PropertyName) == null
                                                ? String.Empty
                                                : previous.Element(subPropertyNameAttribute.PropertyName).Value;
                }
            }
            return(result);
        }