sdk/dotnet/src/Microsoft.Datasync.Client.SQLiteStore/Utils/ColumnDefinition.cs
/// <summary>
/// Deserializes a value of this column type back to the JSON form.
/// </summary>
/// <param name="value">The value to deserialize.</param>
/// <returns>The <see cref="JToken"/> for the value.</returns>
Deserializes a value of this column type back to the JSON form.
Deserializes a value of this column type back to the JSON form .
public JToken DeserializeValue(object value)
        {
            if (value == null)
            {
                return null;
            }
            if (SqlColumnType.IsTextType(StoreType))
            {
                string strValue = value as string;
                return JsonType switch
                {
                    JTokenType.Guid => Guid.Parse(strValue),
                    JTokenType.Bytes => Convert.FromBase64String(strValue),
                    JTokenType.TimeSpan => TimeSpan.Parse(strValue),
                    JTokenType.Uri => new Uri(strValue, UriKind.RelativeOrAbsolute),
                    JTokenType.Array => JToken.Parse(strValue),
                    JTokenType.Object => JToken.Parse(strValue),
                    _ => strValue
                };
            }
            if (SqlColumnType.IsFloatType(StoreType))
            {
                return Convert.ToDouble(value);
            }
            if (SqlColumnType.IsNumberType(StoreType))
            {
                long longValue = Convert.ToInt64(value);
                return JsonType switch
                {
                    JTokenType.Date => epoch.AddMilliseconds(Convert.ToDouble(value)),
                    JTokenType.Boolean => longValue == 1,
                    _ => longValue
                };
            }
            return null;
        }
public JToken DeserializeValue ( object value ) { if ( value == null ) { return null ; } if ( SqlColumnType . IsTextType ( StoreType ) ) { string strValue = value as string ; return JsonType switch { JTokenType . Guid => Guid . Parse ( strValue ) , JTokenType . Bytes => Convert . FromBase64String ( strValue ) , JTokenType . TimeSpan => TimeSpan . Parse ( strValue ) , JTokenType . Uri => new Uri ( strValue , UriKind . RelativeOrAbsolute ) , JTokenType . Array => JToken . Parse ( strValue ) , JTokenType . Object => JToken . Parse ( strValue ) , _ => strValue } ; } if ( SqlColumnType . IsFloatType ( StoreType ) ) { return Convert . ToDouble ( value ) ; } if ( SqlColumnType . IsNumberType ( StoreType ) ) { long longValue = Convert . ToInt64 ( value ) ; return JsonType switch { JTokenType . Date => epoch . AddMilliseconds ( Convert . ToDouble ( value ) ) , JTokenType . Boolean => longValue == 1 , _ => longValue } ; } return null ; }
Deserializes a value of this column type back to the JSON form.
Deserializes a value of this column type back to the JSON form .
The  for the value.
The for the value .
value
object
The value to deserialize.
The value to deserialize .