Skip to content

Commit c5cf99f

Browse files
Ryan Nowakrynowak
authored andcommitted
Add APIs for conversions
This change adds API surface for performing type conversions in the same way that `@bind` will perform them. This allows us to centralize these implementations where it makes sense (form controls). More critically we need to present a uniform API surface for the compiler to use in code generation for converting values to strings using the appropriate culture. Surfacing an API for this and using it from the compiler is the missing piece for `@bind` and globalization (number, date).
1 parent a5411de commit c5cf99f

File tree

10 files changed

+1808
-674
lines changed

10 files changed

+1808
-674
lines changed

src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,53 @@ protected void NotifyAuthenticationStateChanged(System.Threading.Tasks.Task<Micr
2525
public static partial class BindAttributes
2626
{
2727
}
28+
public static partial class BindConverter
29+
{
30+
public static bool FormatValue(bool value, System.Globalization.CultureInfo culture = null) { throw null; }
31+
public static string FormatValue(System.DateTime value, System.Globalization.CultureInfo culture = null) { throw null; }
32+
public static string FormatValue(System.DateTime value, string format, System.Globalization.CultureInfo culture = null) { throw null; }
33+
public static string FormatValue(System.DateTimeOffset value, System.Globalization.CultureInfo culture = null) { throw null; }
34+
public static string FormatValue(System.DateTimeOffset value, string format, System.Globalization.CultureInfo culture = null) { throw null; }
35+
public static string FormatValue(decimal value, System.Globalization.CultureInfo culture = null) { throw null; }
36+
public static string FormatValue(double value, System.Globalization.CultureInfo culture = null) { throw null; }
37+
public static string FormatValue(int value, System.Globalization.CultureInfo culture = null) { throw null; }
38+
public static string FormatValue(long value, System.Globalization.CultureInfo culture = null) { throw null; }
39+
public static bool? FormatValue(bool? value, System.Globalization.CultureInfo culture = null) { throw null; }
40+
public static string FormatValue(System.DateTimeOffset? value, System.Globalization.CultureInfo culture = null) { throw null; }
41+
public static string FormatValue(System.DateTimeOffset? value, string format, System.Globalization.CultureInfo culture = null) { throw null; }
42+
public static string FormatValue(System.DateTime? value, System.Globalization.CultureInfo culture = null) { throw null; }
43+
public static string FormatValue(System.DateTime? value, string format, System.Globalization.CultureInfo culture = null) { throw null; }
44+
public static string FormatValue(decimal? value, System.Globalization.CultureInfo culture = null) { throw null; }
45+
public static string FormatValue(double? value, System.Globalization.CultureInfo culture = null) { throw null; }
46+
public static string FormatValue(int? value, System.Globalization.CultureInfo culture = null) { throw null; }
47+
public static string FormatValue(long? value, System.Globalization.CultureInfo culture = null) { throw null; }
48+
public static string FormatValue(float? value, System.Globalization.CultureInfo culture = null) { throw null; }
49+
public static string FormatValue(float value, System.Globalization.CultureInfo culture = null) { throw null; }
50+
public static string FormatValue(string value, System.Globalization.CultureInfo culture = null) { throw null; }
51+
public static object FormatValue<T>(T value, System.Globalization.CultureInfo culture = null) { throw null; }
52+
public static bool TryConvertToBool(object obj, System.Globalization.CultureInfo culture, out bool value) { throw null; }
53+
public static bool TryConvertToDateTime(object obj, System.Globalization.CultureInfo culture, out System.DateTime value) { throw null; }
54+
public static bool TryConvertToDateTime(object obj, System.Globalization.CultureInfo culture, string format, out System.DateTime value) { throw null; }
55+
public static bool TryConvertToDateTimeOffset(object obj, System.Globalization.CultureInfo culture, out System.DateTimeOffset value) { throw null; }
56+
public static bool TryConvertToDateTimeOffset(object obj, System.Globalization.CultureInfo culture, string format, out System.DateTimeOffset value) { throw null; }
57+
public static bool TryConvertToDecimal(object obj, System.Globalization.CultureInfo culture, out decimal value) { throw null; }
58+
public static bool TryConvertToDouble(object obj, System.Globalization.CultureInfo culture, out double value) { throw null; }
59+
public static bool TryConvertToFloat(object obj, System.Globalization.CultureInfo culture, out float value) { throw null; }
60+
public static bool TryConvertToInt(object obj, System.Globalization.CultureInfo culture, out int value) { throw null; }
61+
public static bool TryConvertToLong(object obj, System.Globalization.CultureInfo culture, out long value) { throw null; }
62+
public static bool TryConvertToNullableBool(object obj, System.Globalization.CultureInfo culture, out bool? value) { throw null; }
63+
public static bool TryConvertToNullableDateTime(object obj, System.Globalization.CultureInfo culture, out System.DateTime? value) { throw null; }
64+
public static bool TryConvertToNullableDateTime(object obj, System.Globalization.CultureInfo culture, string format, out System.DateTime? value) { throw null; }
65+
public static bool TryConvertToNullableDateTimeOffset(object obj, System.Globalization.CultureInfo culture, out System.DateTimeOffset? value) { throw null; }
66+
public static bool TryConvertToNullableDateTimeOffset(object obj, System.Globalization.CultureInfo culture, string format, out System.DateTimeOffset? value) { throw null; }
67+
public static bool TryConvertToNullableDecimal(object obj, System.Globalization.CultureInfo culture, out decimal? value) { throw null; }
68+
public static bool TryConvertToNullableDouble(object obj, System.Globalization.CultureInfo culture, out double? value) { throw null; }
69+
public static bool TryConvertToNullableFloat(object obj, System.Globalization.CultureInfo culture, out float? value) { throw null; }
70+
public static bool TryConvertToNullableInt(object obj, System.Globalization.CultureInfo culture, out int? value) { throw null; }
71+
public static bool TryConvertToNullableLong(object obj, System.Globalization.CultureInfo culture, out long? value) { throw null; }
72+
public static bool TryConvertToString(object obj, System.Globalization.CultureInfo culture, out string value) { throw null; }
73+
public static bool TryConvertTo<T>(object obj, System.Globalization.CultureInfo culture, out T value) { throw null; }
74+
}
2875
[System.AttributeUsageAttribute(System.AttributeTargets.Class, AllowMultiple=true, Inherited=true)]
2976
public sealed partial class BindElementAttribute : System.Attribute
3077
{

0 commit comments

Comments
 (0)