Update of /cvsroot/adapdev/Adapdev/src/Adapdev
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7036/src/Adapdev
Modified Files:
ObjectComparer.cs
Log Message:
Improved ObjectComparer to include field comparisons
Added AssociationType for ForeignKeyAssociations
Improved CacheManager and associated tests
Index: ObjectComparer.cs
===================================================================
RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev/ObjectComparer.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ObjectComparer.cs 25 May 2005 05:17:49 -0000 1.3
--- ObjectComparer.cs 2 Nov 2005 13:45:13 -0000 1.4
***************
*** 1,3 ****
--- 1,4 ----
using System;
+ using System.Reflection;
using Adapdev.Reflection;
***************
*** 15,18 ****
--- 16,24 ----
public static bool AreEqual(object x, object y)
{
+ return AreEqual(x, y, false);
+ }
+
+ public static bool AreEqual(object x, object y, bool includeFields)
+ {
Type t = x.GetType();
ClassAccessor accessor = ClassAccessorCache.Get(t);
***************
*** 31,34 ****
--- 37,46 ----
return false;
}
+
+ if(includeFields)
+ {
+ if(!AreFieldsEqual(x, y)) return false;
+ }
+
return true;
}
***************
*** 38,41 ****
--- 50,62 ----
}
}
+
+ private static bool AreFieldsEqual(object x, object y)
+ {
+ foreach(FieldInfo field in x.GetType().GetFields())
+ {
+ if(!(field.GetValue(x).ToString().Equals(field.GetValue(y).ToString()))) return false;
+ }
+ return true;
+ }
}
}
|