/// <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);
        }
        /// <inheritdoc />
        public string SerializeToString(
            object objectToSerialize)
        {
            string result;

            if (objectToSerialize == null)
            {
                result = null;
            }
            else
            {
                if (objectToSerialize.GetType() != typeof(DateTime))
                {
                    throw new ArgumentException(Invariant($"{nameof(objectToSerialize)}.GetType() != typeof({nameof(DateTime)}); '{nameof(objectToSerialize)}' is of type '{objectToSerialize.GetType().ToStringReadable()}'"));
                }

                result = ObcDateTimeStringSerializer.SerializeToString((DateTime)objectToSerialize);
            }

            return(result);
        }
 public string SerializeToString(
     object objectToSerialize)
 {
     if (objectToSerialize == null)
     {
         return(null);
     }
     else if (objectToSerialize is string objectToSerializeString)
     {
         return(objectToSerializeString);
     }
     else if (objectToSerialize is Guid objectToSerializeGuid)
     {
         return(objectToSerializeGuid.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is bool objectToSerializeBool)
     {
         return(objectToSerializeBool.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is DateTime objectToSerializeDateTime)
     {
         return(ObcDateTimeStringSerializer.SerializeToString(objectToSerializeDateTime));
     }
     else if (objectToSerialize is sbyte objectToSerializeSignedByte)
     {
         return(objectToSerializeSignedByte.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is byte objectToSerializeByte)
     {
         return(objectToSerializeByte.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is short objectToSerializeShort)
     {
         return(objectToSerializeShort.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is ushort objectToSerializeUnsignedShort)
     {
         return(objectToSerializeUnsignedShort.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is int objectToSerializeInt)
     {
         return(objectToSerializeInt.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is uint objectToSerializeUnsignedInt)
     {
         return(objectToSerializeUnsignedInt.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is long objectToSerializeLong)
     {
         return(objectToSerializeLong.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is ulong objectToSerializeUnsignedLong)
     {
         return(objectToSerializeUnsignedLong.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is float objectToSerializeFloat)
     {
         return(objectToSerializeFloat.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is double objectToSerializeDouble)
     {
         return(objectToSerializeDouble.ToStringInvariantPreferred());
     }
     else if (objectToSerialize is decimal objectToSerializeDecimal)
     {
         return(objectToSerializeDecimal.ToStringInvariantPreferred());
     }
     else
     {
         return(this.FallbackSerializer.SerializeToString(objectToSerialize));
     }
 }
 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));
     }
 }