/// <inheritdoc /> public object Deserialize( string serializedString, Type type) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (type != typeof(DateTime?)) { throw new ArgumentException(Invariant($"{nameof(type)} != typeof({nameof(DateTime)}?); '{nameof(type)}' is of type '{type.ToStringReadable()}'")); } object result; if (serializedString == null) { result = null; } else { result = ObcDateTimeStringSerializer.DeserializeToDateTime(serializedString); } return(result); }
public object Deserialize( string serializedString, Type type) { if (serializedString == null) { return(null); } else if (type == typeof(string)) { return(serializedString); } else if ((type == typeof(Guid)) || (type == typeof(Guid?))) { return(Guid.Parse(serializedString)); } else if ((type == typeof(bool)) || (type == typeof(bool?))) { return(bool.Parse(serializedString)); } else if ((type == typeof(DateTime)) || (type == typeof(DateTime?))) { return(ObcDateTimeStringSerializer.DeserializeToDateTime(serializedString)); } else if ((type == typeof(sbyte)) || (type == typeof(sbyte?))) { return(sbyte.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(byte)) || (type == typeof(byte?))) { return(byte.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(short)) || (type == typeof(short?))) { return(short.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(ushort)) || (type == typeof(ushort?))) { return(ushort.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(int)) || (type == typeof(int?))) { return(int.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(uint)) || (type == typeof(uint?))) { return(uint.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(long)) || (type == typeof(long?))) { return(long.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(ulong)) || (type == typeof(ulong?))) { return(ulong.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(float)) || (type == typeof(float?))) { return(float.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(double)) || (type == typeof(double?))) { return(double.Parse(serializedString, CultureInfo.InvariantCulture)); } else if ((type == typeof(decimal)) || (type == typeof(decimal?))) { return(decimal.Parse(serializedString, CultureInfo.InvariantCulture)); } else { return(this.FallbackSerializer.Deserialize(serializedString, type)); } }