From 91015866b5eb131bee15345417311808fd4f7345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Leb=C3=A9e?= Date: Tue, 17 Apr 2018 21:35:42 -0500 Subject: [PATCH] documentation. --- PoweredSoft.Types.Test/ConvertionTests.cs | 2 +- PoweredSoft.Types.sln | 5 ++++ README.md | 30 +++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/PoweredSoft.Types.Test/ConvertionTests.cs b/PoweredSoft.Types.Test/ConvertionTests.cs index 0766de7..e4a4c0d 100644 --- a/PoweredSoft.Types.Test/ConvertionTests.cs +++ b/PoweredSoft.Types.Test/ConvertionTests.cs @@ -61,7 +61,7 @@ namespace PoweredSoft.Types.Test var a1 = "12345"; var b1 = a1.To(typeof(int?)); - Assert.AreEqual(b1, 12345); + Assert.AreEqual(12345, b1); } } } diff --git a/PoweredSoft.Types.sln b/PoweredSoft.Types.sln index c451779..ae4e275 100644 --- a/PoweredSoft.Types.sln +++ b/PoweredSoft.Types.sln @@ -7,6 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.Types", "Powere EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoweredSoft.Types.Test", "PoweredSoft.Types.Test\PoweredSoft.Types.Test.csproj", "{7CB0B9D3-8B0C-4A3E-9A1B-8DB4A8C4646E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{19332C1E-B9CD-4332-9F1E-D237611DF59B}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/README.md b/README.md new file mode 100644 index 0000000..3ff0dcb --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +## Download +Full Version | NuGet | NuGet Install +------------ | :-------------: | :-------------: +PoweredSoft.Types | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.Types.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.Types/) | ```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 + +```csharp +var codeStr = "123"; +var code = codeStr.To(typeof(int)); +Assert.Equal(123, code); +``` + +# Adding converters or replacing default converters + +```csharp +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)); +``` \ No newline at end of file