static public void CompareComponents(ComponentBase cb1, ComponentBase cb2) { Type type = cb1.GetType(); Assert.IsTrue(type == cb2.GetType(), "Types do not match"); FieldInfo[] fields = type.GetFields(); PropertyInfo[] properties = type.GetProperties(); foreach (FieldInfo field in fields) { if (field.GetCustomAttributes(typeof(SerializedAttribute), true).Length > 0) { object obj1 = field.GetValue(cb1); object obj2 = field.GetValue(cb2); if (field.FieldType.IsArray) CompareEnumerables(obj1 as Array, obj2 as Array, field.Name); else Assert.IsTrue(object.Equals(obj1, obj2), field.Name + " does not match"); } } foreach (PropertyInfo prop in properties) { if (prop.GetCustomAttributes(typeof(SerializedAttribute), true).Length > 0) { object obj1 = prop.GetValue(cb1, null); object obj2 = prop.GetValue(cb2, null); if (typeof(IEnumerable).IsAssignableFrom(prop.PropertyType)) CompareEnumerables(obj1 as Array, obj2 as Array, prop.Name); else Assert.IsTrue(object.Equals(obj1, obj2), prop.Name + " does not match"); } } }
public ComponentBaseSerializer(DDay.iCal.Components.ComponentBase component) : base(component) { Component = component; }