refactor(ObjectExtensions): add and bind ToCamelCase-method
This commit is contained in:
parent
786086a260
commit
a7cbced3e6
@ -11,7 +11,7 @@ public static class ObjectExtensions
|
|||||||
.GetType()
|
.GetType()
|
||||||
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
prop => prop.Name,
|
prop => prop.Name.ToCamelCase(),
|
||||||
prop => prop.GetValue(obj).ToSafeString()
|
prop => prop.GetValue(obj).ToSafeString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ public static class ObjectExtensions
|
|||||||
{
|
{
|
||||||
return obj
|
return obj
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
prop => prop.Key,
|
prop => prop.Key.ToCamelCase(),
|
||||||
prop => prop.Value?.ToString()
|
prop => prop.Value?.ToString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -37,4 +37,15 @@ public static class ObjectExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string? AddQueryString(this string? route, object queryParams) => route.AddQueryString(queryParams.ToPropertyDictionary());
|
public static string? AddQueryString(this string? route, object queryParams) => route.AddQueryString(queryParams.ToPropertyDictionary());
|
||||||
|
|
||||||
|
public static string ToCamelCase(this string input)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(input))
|
||||||
|
return input;
|
||||||
|
|
||||||
|
if (char.IsLower(input[0]))
|
||||||
|
return input;
|
||||||
|
|
||||||
|
return char.ToLowerInvariant(input[0]) + input[1..];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user