Data Type Conversions

The conversion library built into the BizArk Toolkit provides the conversion library that should have been built into .Net. It supports all the conversions that you would expect the .Net framework to support (but doesn't) plus many others. This library is used throughout the BizArk toolkit to do conversions (such as converting command-line parameters to their correct type, converting web parameters in WebHelper to strings, etc).

Example of using ConvertEx:
var pt = ConvertEx.To<Point>("1,2");


To use ConvertEx, simply call one of the ConvertEx methods. There are a number of helper methods to convert values to basic types such as integer, string, boolean, etc. However, you can also call ConvertEx.ChangeType or ConvertEx.To (an alias for ChangeType) to convert between any two types (as long as one of the types supports conversions from the other type).

ConvertEx also provides a plugin architecture if you want to extend the types that it can convert to/from. To use it, just create a class that implements the Redwerb.BizArk.Core.Convert.IConvertStrategy interface and register it by calling Redwerb.BizArk.Core.Convert.ConvertStrategyMgr.RegisterStrategy.