Skip to content

joshua-honig/ockham.net.data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ockham.Data

Basic data inspection and conversion utilities. Part of the Ockham.Net project.

The Problem

Every Ockham component should solve a clear problem that is not solved in the .Net BCL, or in the particular libraries it is meant to augment.

The utilities in this library provide robust, configurable data inspection and conversion utilities. These are particularly useful when serializing and deserializing to databases or other external sources, and when working with dynamic data.

Data Conversion

The existing basic data conversions available from the System.Convert and Microsoft.VisualBasic.CompilerServices.Conversions classes fail in several cases that arise frequently when working with serialization and deserialization:

  • Converting to and from DBNull
  • Converting to and from Nullable<T> values
  • Converting to and from enums
  • Converting to and from Guids
  • Converting to any target type with generic method syntax (both System.Convert.ChangeType and Conversions.ChangeType are non-generic methods that require a runtime type value and return a object)

The different conversion and inspection functions of the Convert static class and Converter instance class, along with the various flags of the ConvertOptions enumeration, provide succinct and intuitive conversions that can also be adjusted for the desired specifics, such as:

  • Treating an empty string as null (or not)
  • Recognizing hexadecimal strings (or not)
  • Converting null values to the default value of a value type (or not)
  • Coercing any value to a particular target type, with or without an explicit fallback value (or not)

Type Inspection

The BCL lacks succinct methods for checking if a value or a type is numeric, whether a type implements a variation of an open generic interface, or whether a type is a constructed form of a open generic class

About

Ockham.Data module of the Ockham.Net project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published