Package for type conversion.
Go to file
2018-10-12 18:02:08 -05:00
PoweredSoft.Types Add project files. 2018-04-17 21:16:22 -05:00
PoweredSoft.Types.Test documentation. 2018-04-17 21:35:42 -05:00
.gitattributes Add .gitignore and .gitattributes. 2018-04-17 21:16:21 -05:00
.gitignore Add .gitignore and .gitattributes. 2018-04-17 21:16:21 -05:00
LICENSE.md Rename LICENSE to LICENSE.md 2018-10-12 18:02:08 -05:00
PoweredSoft.Types.sln documentation. 2018-04-17 21:35:42 -05:00
README.md documentation. 2018-04-17 21:35:42 -05:00

Download

Full Version NuGet NuGet Install
PoweredSoft.Types NuGet PM> Install-Package PoweredSoft.Types

Reason of package

This package is for other packages of our company, but if you find usage for it, enjoy.

Sample

var codeStr = "123";
var code = codeStr.To(typeof(int));
Assert.Equal(123, code);

Adding converters or replacing default converters

class StringToIntConverter : ITypeConverter
{
	public bool CanConvert(Type source, Type destination) => source == typeof(string) && destination == typeof(int);
	public object Convert(object source, Type destination) => Convert.ToInt32(source);
}

Converter.RegisterConverter(new ConverterClass());
Converter.ReplaceConverter(new ConverterClass(), typeof(string), typeof(int));