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(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())); }
private static bool TextValuesAreEqual(Value value1, Value value2) { return String.Equals((value1 as TextValue).value, (value2 as TextValue).value); }
private static bool DateTimeValuesAreEqual(Value value1, Value value2) { DateTime dateTime1 = (value1 as DateTimeValue).value; DateTime dateTime2 = (value2 as DateTimeValue).value; return DatesAreEqual(dateTime1.date, dateTime2.date) && dateTime1.hour == dateTime2.hour && dateTime1.minute == dateTime2.minute && dateTime1.second == dateTime2.second && String.Equals(dateTime1.timeZoneID, dateTime2.timeZoneID); }
private static bool BooleanValuesAreEqual(Value value1, Value value2) { return (value1 as BooleanValue).value == (value2 as BooleanValue).value; }
/// <summary> /// Gets the underlying value of the Value object. /// </summary> /// <value>The Value object to get the value from.</value> /// <returns>The underlying value.</returns> public static object GetValue(Value value) { PropertyInfo propInfo = value.GetType().GetProperty("value"); if (propInfo != null) { return propInfo.GetValue(value, null); } return null; }
/// <summary> /// Adds a new value to the list of query parameters. /// </summary> /// <param name="key">The parameter name.</param> /// <param name="value">The parameter value.</param> /// <returns>The statement builder, for chaining method calls.</returns> private StatementBuilder AddValue(string key, Value value) { String_ValueMapEntry queryValue = new String_ValueMapEntry(); queryValue.key = key; queryValue.value = value; valueEntries.Add(queryValue); return this; }