コード例 #1
0
        private TargetDiff CreateDiff(TargetModel left, TargetModel right)
        {
            var diff = new TargetDiff();

            Type targetModelType = typeof(TargetModel);

            MemberInfo[] members = targetModelType.GetMembers(BindingFlags.Public | BindingFlags.Instance);

            diff.Diffs = new Dictionary <string, StringsDiff>();

            // Create a diff for each list of strings in the type
            Type listStringT = typeof(List <string>);

            foreach (var memberInfo in members)
            {
                if ((memberInfo.MemberType == MemberTypes.Field) &&
                    memberInfo.GetUnderlyingType() == listStringT)
                {
                    var leftStrs  = (List <string>)((FieldInfo)memberInfo).GetValue(left);
                    var rightStrs = (List <string>)((FieldInfo)memberInfo).GetValue(right);

                    if ((leftStrs != null) && (rightStrs != null))
                    {
                        diff.Diffs[memberInfo.Name] = CreateDiff(leftStrs, rightStrs);
                    }
                }
            }

            return(diff);
        }
コード例 #2
0
 private void OutputTargetDiff(TargetDiff diff)
 {
     foreach (string key in diff.Diffs.Keys)
     {
         OutputHeader(2, key);
         OutputStringsDiff(diff.Diffs[key]);
     }
 }