public class Program
    {
        [DebuggerDisplay("Name={Name}, Age={Age}")]
        public sealed class Student
        {
            [Flags]
            public enum Fields
            {
                None,
                Name,
                Age
            }

            public string Name;
            public int Age;
        }


        static void Main(string[] args)
        {
            var oldData = new List<Student>
                              {
                                  new Student { Name = "Joe", Age = 10},
                                  new Student { Name = "Moe", Age = 1},
                                  new Student { Name = "Shmoe", Age = 10 }
                              };
            var newData = new List<Student>
                              {
                                  new Student { Name = "Joe", Age = 10},
                                  new Student { Name = "Moe", Age = 2 },
                                  new Student { Name = "Bo", Age = 10 }
                              };

            var diff = Differ<Student>.Diff(oldData, newData,
                (a, b) => string.Compare(a.Name, b.Name),
                (a, b) => (a.Name == b.Name) && (a.Age == b.Age) ? 0 : 1).ToArray();
        }
    }

Last edited Jan 5, 2012 at 9:34 PM by ananth, version 1

Comments

No comments yet.