Transformations 0.0.10
See the version list below for details.
dotnet add package Transformations --version 0.0.10
NuGet\Install-Package Transformations -Version 0.0.10
<PackageReference Include="Transformations" Version="0.0.10" />
paket add Transformations --version 0.0.10
#r "nuget: Transformations, 0.0.10"
// Install Transformations as a Cake Addin #addin nuget:?package=Transformations&version=0.0.10 // Install Transformations as a Cake Tool #tool nuget:?package=Transformations&version=0.0.10
Conversion between data types. Envisaged as a possible alternative to the Universal Type Converter http://www.codeproject.com/Articles/248440/Universal-Type-Converter, with the provision for default values, and some extra features.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
This package has no dependencies.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.38 | 73 | 5/7/2015 |
0.0.37 | 73 | 5/7/2015 |
0.0.36 | 60 | 5/7/2015 |
0.0.35 | 66 | 5/7/2015 |
0.0.34 | 70 | 5/7/2015 |
0.0.33 | 54 | 5/7/2015 |
0.0.32 | 73 | 5/6/2015 |
0.0.31 | 64 | 5/6/2015 |
0.0.30 | 66 | 5/6/2015 |
0.0.29 | 68 | 5/6/2015 |
0.0.28 | 53 | 5/6/2015 |
0.0.27 | 68 | 5/5/2015 |
0.0.26 | 71 | 5/5/2015 |
0.0.25 | 72 | 4/27/2015 |
0.0.24 | 68 | 4/24/2015 |
0.0.23 | 87 | 4/23/2015 |
0.0.22 | 91 | 4/2/2015 |
0.0.21 | 65 | 4/2/2015 |
0.0.20 | 75 | 4/1/2015 |
0.0.19 | 70 | 3/31/2015 |
0.0.18 | 68 | 3/31/2015 |
0.0.17 | 63 | 3/31/2015 |
0.0.16 | 72 | 3/31/2015 |
0.0.15 | 68 | 3/31/2015 |
0.0.14 | 56 | 3/31/2015 |
0.0.13 | 62 | 3/31/2015 |
0.0.12 | 75 | 3/30/2015 |
0.0.11 | 69 | 3/30/2015 |
0.0.10 | 63 | 3/30/2015 |
0.0.9 | 68 | 3/30/2015 |
0.0.8 | 54 | 3/30/2015 |
0.0.7 | 62 | 3/30/2015 |
0.0.6 | 141 | 5/2/2014 |
0.0.5 | 91 | 5/2/2014 |
0.0.4 | 90 | 4/24/2014 |
0.0.3 | 94 | 4/23/2014 |
0.0.2 | 64 | 4/23/2014 |
0.0.1 | 105 | 4/17/2014 |
* You don't need to reference the transformations namespace with Using statement (type conversions are meant to be universal if you choose to use this).
Generally you would just do:
var newValue = oldValue.ConvertTo<newType>(optionalDefaultValue);
* You can use TryConvertTo if you need to get the result of the conversion process.
* You can do some conversions on DataTables and Lists , for example convert a data table to an object list, if the names of the columns match the object properties.
* The date conversion is set to British date format by default, not the project's current format. This may have to change to make the library more "universal".
* From some basic tests I have performed on universal type converter and this library, I found it to be a bit faster than the universal type converter...
********************************************
Some examples of use:
********************************************
string valueInput = "7F8C14B6-B3A8-4F71-8EFC-E5A7B35923B6";
Guid actual = valueInput.ConvertTo<Guid>(Guid.Empty);
// -----------------------------------------------
string valueInput = "0.1";
float actual = valueInput.ConvertTo<float>(0.0f);
// result = 0.1f;
// -----------------------------------------------
string valueInput = "15/02/2014";
DateTime actual = valueInput.ConvertTo<DateTime>(new DateTime(2000, 01, 01));
// result = new DateTime(2014, 02, 15);
// -----------------------------------------------
float? f = 123.524f;
int? i = f.ConvertTo<int>();
// result = 124;
// -----------------------------------------------
* You can convert date to 'excel'-type value:
DateTime d = new DateTime(2005, 5, 5);
d.ToDouble();
// or d.ToInt();
List conversions examples:
// -----------------------------------------------
List<int> l1 = new List<int>(new int[] { 2, 3, 4 });
List<float> l2 = l1.ConvertToList<int, float>();
// -----------------------------------------------
**************************************************
Some additional helper methods are added as extensions as well:
// -----------------------------------------------
*Proper Case*
string name = "mr john smith";
name.ProperCase();
// result = "Mr John Smith";
// -----------------------------------------------
*Insert Spaces*
string name = "MrJohnSmith";
name.InsertSpaces();
// result = "Mr John Smith";
// -----------------------------------------------
*Remove Chars* - removes multiple instances of the same string pattern from the string.
string name = "Mr John John Smith";
name.RemoveChars("John ");
// result = "Mr Smith";
// -----------------------------------------------
*Replace Ex* - replace multiple instances of the same string pattern in the string.
string s = "12345678901234567890";
s.ReplaceEx("2", "X");
// result = "1X345678901X34567890";
// -----------------------------------------------
*Is Date* - check if string is a date! assumes en-Gb as default culture at present..
string s = "14/02/2014";
if (IsDate(s))
{ ... }
if (IsDate(s, "en-GB"))
{ ... }
// -----------------------------------------------
{ Your comments are VERY welcome! }