private static bool ValuesAreEqual(Value value1, Value value2) {
       Dictionary<Type, ValueEqualityDelegate> switcher = 
         new Dictionary<Type, ValueEqualityDelegate>();
      switcher.Add(typeof(TextValue), new ValueEqualityDelegate(TextValuesAreEqual));
      switcher.Add(typeof(NumberValue), new ValueEqualityDelegate(NumberValuesAreEqual));
      switcher.Add(typeof(BooleanValue), new ValueEqualityDelegate(BooleanValuesAreEqual));
      switcher.Add(typeof(SetValue), new ValueEqualityDelegate(SetValuesAreEqual));
      switcher.Add(typeof(DateValue), new ValueEqualityDelegate(DateValuesAreEqual));
      switcher.Add(typeof(DateTimeValue), new ValueEqualityDelegate(DateTimeValuesAreEqual));

      if (switcher.ContainsKey(value1.GetType())) {
        return switcher[value1.GetType()](value1, value2);
      }
      throw new NotImplementedException(String.Format("Unknown Value type {0}", value1.GetType()));
    }
 /// <summary>
 /// Gets the underlying value of the Value object. For SetValues, returns
 /// a List of underlying values.
 /// </summary>
 /// <value>The Value object to get the value from.</value>
 /// <returns>The underlying value, or List of underlying values from a SetValue.</returns>
 public static object GetValue(Value value) {
   if (value is SetValue) {
     PropertyInfo propInfo = value.GetType().GetProperty("values");
     if(propInfo != null) {
       Value[] setValues = propInfo.GetValue(value, null) as Value[];
       List<object> extractedValues = new List<object>();
       foreach (Value setValue in setValues) {
         validateSetValueForSet(GetValue(setValue), extractedValues);
         extractedValues.Add(GetValue(setValue));
       }
       return extractedValues;
     }
   } else {
     PropertyInfo propInfo = value.GetType().GetProperty("value");
     if (propInfo != null) {
       return propInfo.GetValue(value, null);
     }
   }
   return null;
 }