Skip to content

Converts a data type to another data type, smarter than the standard Convert class, including collections and their items as well as object properties (duck typing). With special support for DateTime conversions.

License

ygoe/DeepConvert

Repository files navigation

DeepConvert

Converts a data type to another data type, smarter than the standard Convert class, including collections and their items as well as object properties (duck typing). With special support for DateTime conversions.

NuGet

Supports .NET Standard 2.0 and .NET Framework 4.5.

Description

The System.Convert class provides methods to convert values from one type into another. This is restricted to the IConvertible interface which mainly covers basic numeric types and a few more like boolean, string or DateTime. Its efforts in trying more complex conversions are very limited. Collections of values are completely unsupported by that class.

Serialisation and deserialisation libraries provide data in a very specific structure that may not match the program’s requirements. Converting an array of integer values into a list of long values or the like often require manual copy implementations. It gets even more complicated when mapping a dictionary with objects to one with strings, or even a flat list with key/value pairs to a dictionary.

The DeepConvert class solves all these problems by supporting a larger number of basic data types and many collections thereof. Its special tricks include understanding localised boolean values and extended parsing and converting of time-based values. This also allows conversions between .NET ticks, UNIX timestamp seconds or JavaScript timestamp milliseconds.

Tests

This library is covered by some unit tests but has no near full code coverage yet. The unit tests can be used to get an overview of supported conversions until a more detailed documentation is available. It should also be easy to follow the IntelliSense documentation of static method lists and parameter descriptions.

License

MIT license

About

Converts a data type to another data type, smarter than the standard Convert class, including collections and their items as well as object properties (duck typing). With special support for DateTime conversions.

Topics

Resources

License

Stars

Watchers

Forks

Languages