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
Copy file name to clipboardExpand all lines: docs/articles/features/data-converters.md
+54-1Lines changed: 54 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,30 @@ These can be used to convert any type to another. Whatever data conversion you t
58
58
59
59
If there is a common value converter you think is missing from MADE.NET, [raise a tracking item on GitHub](https://github.com/MADE-Apps/MADE.NET/issues/new/choose) and we'll get it implemented.
60
60
61
+
## Converting strings to enums using the StringToEnumValueConverter
62
+
63
+
The `MADE.Data.Converters.StringToEnumValueConverter<TEnum>` converts between string values and enum types. It supports case-insensitive matching by default.
Set `IgnoreCase` to `false` if you need exact case matching. The converter throws `InvalidDataConversionException` if the string cannot be parsed as the target enum type.
73
+
74
+
## Converting DateTime to Unix timestamps using the DateTimeToUnixTimestampValueConverter
75
+
76
+
The `MADE.Data.Converters.DateTimeToUnixTimestampValueConverter` converts between `DateTime` and Unix timestamps (seconds since 1970-01-01 UTC).
The `MADE.Data.Converters.Extensions.MathExtensions` class provides extensions for common mathematic expressions including `ToRadians` to convert a degrees value to radians.
135
+
The `MADE.Data.Converters.Extensions.MathExtensions` class provides extensions for common mathematic expressions:
136
+
137
+
-`ToRadians()` - Converts a degrees value to radians.
138
+
-`ToDegrees()` - Converts a radians value to degrees.
100
139
101
140
## Length extensions
102
141
103
142
The `MADE.Data.Converters.Extensions.LengthExtensions` class provides extensions for converting length values:
104
143
105
144
-`ToMeters()` - Converts a value from miles to meters.
106
145
-`ToMiles()` - Converts a value from meters to miles.
146
+
-`KilometersToMeters()` / `ToKilometers()` - Converts between kilometers and meters.
147
+
-`FeetToMeters()` / `ToFeet()` - Converts between feet and meters.
148
+
-`InchesToMeters()` / `ToInches()` - Converts between inches and meters.
149
+
150
+
## File size extensions
151
+
152
+
The `MADE.Data.Converters.Extensions.FileSizeExtensions` class provides extensions for converting byte values to human-readable file size strings:
153
+
154
+
-`ToHumanReadableFileSize()` - Converts a byte count to a string such as "1.50 MB" or "256 B".
Copy file name to clipboardExpand all lines: docs/articles/intro.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,10 +66,14 @@ It includes features such as:
66
66
67
67
- BooleanToStringValueConverter, a value converter for converting `bool` values to configurable `String` representations, with the capability to convert back.
68
68
- DateTimeToStringValueConverter, a value converter that takes a `DateTime` string format parameter to convert a `DateTime` value to a `String`, with the capability to convert back.
69
-
- DateTimeExtensions, a collection of useful extensions for interacting with `DateTime` values including `ToCurrentAge` (to get an age in years based on a given date from today), `StartOfDay`/`EndOfDay`, `StartOfWeek`/`EndOfWeek`, `StartOfMonth`/`EndOfMonth`, `StartOfYear`/`EndOfYear`, and `ToNearestHour`.
70
-
- MathExtensions, a collection of extensions for common mathematic expressions including `ToRadians` (to convert a degrees value to radians).
71
-
- StringExtensions, a collection of extensions for manipulating `String` values such as `ToTitleCase`, `ToDefaultCase`, `Truncate`, `ToBase64`, `FromBase64`, `ToInt`, `ToBoolean`, `ToFloat`, and `ToDouble`.
72
-
- LengthExtensions, for converting length values such as `ToMeters` and `ToMiles`.
69
+
- StringToEnumValueConverter, a generic value converter for converting between `String` and any `Enum` type with case-insensitive matching.
70
+
- DateTimeToUnixTimestampValueConverter, a value converter between `DateTime` and Unix timestamps.
71
+
- DateTimeExtensions, a collection of useful extensions for interacting with `DateTime` values including `ToCurrentAge`, `StartOfDay`/`EndOfDay`, `StartOfWeek`/`EndOfWeek`, `StartOfMonth`/`EndOfMonth`, `StartOfYear`/`EndOfYear`, and `ToNearestHour`.
72
+
- TimeSpanExtensions, providing `ToHumanReadableString` and `TotalWeeks`.
73
+
- MathExtensions, providing `ToRadians` and `ToDegrees` for angle conversions.
74
+
- StringExtensions, a collection of extensions for manipulating `String` values such as `ToTitleCase`, `ToDefaultCase`, `Truncate`, `ToBase64`, `FromBase64`, `ToSlug`, `ToInt`, `ToBoolean`, `ToFloat`, and `ToDouble`.
75
+
- LengthExtensions, for converting between miles, meters, kilometers, feet, and inches.
76
+
- FileSizeExtensions, for converting byte counts to human-readable file size strings.
73
77
- BooleanExtensions, for formatting `bool` values to custom string representations with `ToFormattedString`.
0 commit comments