You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
internal object SerializeRedisValue(object value)
{
if (value != null)
{
if (!(value is string) && !(value is byte[]))
{
if (!(value is bool))
{
if (!(value is char))
{
if (!(value is decimal) && !(value is double) && !(value is float) && !(value is int) && !(value is long) && !(value is sbyte) && !(value is short) && !(value is uint) && !(value is ulong) && !(value is ushort))
{
if (!(value is DateTime dateTime))
{
if (!(value is DateTimeOffset))
{
if (!(value is TimeSpan timeSpan))
{
if (value is Guid)
{
return value.ToString();
}
if (Adapter.TopOwner.Serialize != null)
{
return Adapter.TopOwner.Serialize(value);
}
return value.ConvertTo<string>();
}
return timeSpan.Ticks;
}
return value.ToString();
}
return dateTime.ToString("yyyy-MM-ddTHH:mm:sszzzz", DateTimeFormatInfo.InvariantInfo);
}
return value.ToInvariantCultureToString();
}
return value;
}
return ((bool)value) ? "1" : "0";
}
return value;
}
return null;
}
internal T DeserializeRedisValue(byte[] valueRaw, Encoding encoding)
{
if (valueRaw == null)
{
return default(T);
}
Type typeFromHandle = typeof(T);
string text = typeFromHandle.ToString().TrimEnd(']');
switch (text)
{
case "System.Byte[":
return (T)Convert.ChangeType(valueRaw, typeFromHandle);
case "System.String":
return (T)Convert.ChangeType(encoding.GetString(valueRaw), typeFromHandle);
case "System.Boolean[":
return (T)Convert.ChangeType(valueRaw.Select((byte a) => a == 49).ToArray(), typeFromHandle);
default:
{
if (valueRaw.Length == 0)
{
return default(T);
}
string text2 = null;
if (typeFromHandle.IsValueType)
{
text2 = encoding.GetString(valueRaw);
string text3 = (text.StartsWith("System.Nullable`1[") ? text.Substring(18) : text);
bool flag = false;
object obj = null;
long result2;
switch (text3)
{
case "System.Boolean":
if (text2 == "1")
{
obj = true;
}
else if (text2 == "0")
{
obj = false;
}
break;
case "System.Byte":
{
if (byte.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result8))
{
obj = result8;
}
break;
}
case "System.Char":
if (text2.Length > 0)
{
obj = text2[0];
}
break;
case "System.Decimal":
{
if (decimal.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result4))
{
obj = result4;
}
break;
}
case "System.Double":
{
if (double.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result13))
{
obj = result13;
}
break;
}
case "System.Single":
{
if (float.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result10))
{
obj = result10;
}
break;
}
case "System.Int32":
{
if (int.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result6))
{
obj = result6;
}
break;
}
case "System.Int64":
if (long.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out result2))
{
obj = result2;
}
break;
case "System.SByte":
{
if (sbyte.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result14))
{
obj = result14;
}
break;
}
case "System.Int16":
{
if (short.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result12))
{
obj = result12;
}
break;
}
case "System.UInt32":
{
if (uint.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result11))
{
obj = result11;
}
break;
}
case "System.UInt64":
{
if (ulong.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result9))
{
obj = result9;
}
break;
}
case "System.UInt16":
{
if (ushort.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var result7))
{
obj = result7;
}
break;
}
case "System.DateTime":
{
if (DateTime.TryParse(text2, out var result5))
{
obj = result5;
}
break;
}
case "System.DateTimeOffset":
{
if (DateTimeOffset.TryParse(text2, out var result3))
{
obj = result3;
}
break;
}
case "System.TimeSpan":
if (long.TryParse(text2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out result2))
{
obj = new TimeSpan(result2);
}
break;
case "System.Guid":
{
if (Guid.TryParse(text2, out var result))
{
obj = result;
}
break;
}
default:
flag = true;
break;
}
if (!flag)
{
if (obj == null)
{
return default(T);
}
return (T)obj;
}
}
if (Adapter.TopOwner.DeserializeRaw != null)
{
return (T)Adapter.TopOwner.DeserializeRaw(valueRaw, typeof(T));
}
if (text2 == null)
{
text2 = encoding.GetString(valueRaw);
}
if (Adapter.TopOwner.Deserialize != null)
{
return (T)Adapter.TopOwner.Deserialize(text2, typeof(T));
}
return text2.ConvertTo<T>();
}
}
}
The text was updated successfully, but these errors were encountered:
internal T DeserializeRedisValue(byte[] valueRaw, Encoding encoding)
{
if (valueRaw == null)
{
return default(T);
}
}
The text was updated successfully, but these errors were encountered: