Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
morrisjdev committed Mar 18, 2020
1 parent 1c07cd3 commit d6b7fa8
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions FileContextCore/Serializer/SerializerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static object Deserialize(this string input, Type type)
return type.GetDefaultValue();
}

type = Nullable.GetUnderlyingType(type) ?? type;
type = Nullable.GetUnderlyingType(type) ?? type;

if (type == typeof(DateTimeOffset))
{
Expand All @@ -29,12 +29,12 @@ public static object Deserialize(this string input, Type type)
{
return TimeSpan.Parse(input, CultureInfo.InvariantCulture);
}

if (type == typeof(Guid))
{
return Guid.Parse(input);
}

if (type.IsArray)
{
Type arrType = type.GetElementType();
Expand All @@ -47,7 +47,7 @@ public static object Deserialize(this string input, Type type)

return arr.ToArray();
}

if (type.IsEnum)
{
return Enum.Parse(type, input);
Expand All @@ -64,7 +64,7 @@ public static string Serialize(this object input)
{
string result = "";

object[] arr = (object[])input;
object[] arr = (object[]) input;

for (int i = 0; i < arr.Length; i++)
{
Expand All @@ -79,19 +79,22 @@ public static string Serialize(this object input)
return result;
}

return input is IFormattable formattable ? formattable.ToString(null, CultureInfo.InvariantCulture) : input.ToString();
}
return input is IFormattable formattable
? formattable.ToString(null, CultureInfo.InvariantCulture)
: input.ToString();
}

return "";
}

public static TKey GetKey<TKey, T>(IPrincipalKeyValueFactory<T> keyValueFactory, IEntityType entityType, Func<string, string> valueSelector)
public static TKey GetKey<TKey, T>(IPrincipalKeyValueFactory<T> keyValueFactory, IEntityType entityType,
Func<string, string> valueSelector)
{
return (TKey)keyValueFactory.CreateFromKeyValues(
return (TKey) keyValueFactory.CreateFromKeyValues(
entityType.FindPrimaryKey().Properties
.Select(p =>
valueSelector(p.GetColumnName())
.Deserialize(p.GetValueConverter()?.ProviderClrType ?? p.ClrType)).ToArray());
}
}
}
}

0 comments on commit d6b7fa8

Please sign in to comment.