public SingleValue(object value) { if (SingleValue.IsAllowedValue(value) == false) { throw new ArgumentException("value must by a geocode, string, datetime or primitive type."); } if (value is DateTime) { this.Value = ((DateTime)value).ToString("o"); } else { this.Value = value.ToString(); } }
public static Value FromObject(object obj) { if (obj == null) { return(NullValue.Instance); } if (obj.IsMultiValued() == true) { return(new MultiValue(obj as IEnumerable)); } if (SingleValue.IsAllowedValue(obj) == true) { return(new SingleValue(obj)); } throw new Exception(obj.GetType().Name + " cannot be converted to a Value object."); }