├── .gitattributes ├── docs ├── api │ ├── fti │ │ ├── FTI_120.json │ │ ├── FTI_119.json │ │ ├── FTI_104.json │ │ └── FTI_108.json │ ├── icons │ │ ├── CFW.gif │ │ ├── xna.gif │ │ ├── Search.png │ │ ├── static.gif │ │ ├── TocClose.gif │ │ ├── TocOpen.gif │ │ ├── favicon.ico │ │ ├── pubclass.gif │ │ ├── pubevent.gif │ │ ├── pubfield.gif │ │ ├── slMobile.gif │ │ ├── AlertNote.png │ │ ├── CodeExample.png │ │ ├── TocExpanded.gif │ │ ├── privclass.gif │ │ ├── privevent.gif │ │ ├── privfield.gif │ │ ├── privmethod.gif │ │ ├── protclass.gif │ │ ├── protevent.gif │ │ ├── protfield.gif │ │ ├── protmethod.gif │ │ ├── pubdelegate.gif │ │ ├── pubmethod.gif │ │ ├── puboperator.gif │ │ ├── pubproperty.gif │ │ ├── AlertCaution.png │ │ ├── AlertSecurity.png │ │ ├── TocCollapsed.gif │ │ ├── privdelegate.gif │ │ ├── privextension.gif │ │ ├── privinterface.gif │ │ ├── privproperty.gif │ │ ├── privstructure.gif │ │ ├── protdelegate.gif │ │ ├── protextension.gif │ │ ├── protinterface.gif │ │ ├── protoperator.gif │ │ ├── protproperty.gif │ │ ├── protstructure.gif │ │ ├── pubextension.gif │ │ ├── pubinterface.gif │ │ ├── pubstructure.gif │ │ ├── SectionCollapsed.png │ │ ├── SectionExpanded.png │ │ ├── privenumeration.gif │ │ ├── protenumeration.gif │ │ └── pubenumeration.gif │ ├── styles │ │ ├── branding-cs-CZ.css │ │ ├── branding-de-DE.css │ │ ├── branding-en-US.css │ │ ├── branding-es-ES.css │ │ ├── branding-fr-FR.css │ │ ├── branding-it-IT.css │ │ ├── branding-pl-PL.css │ │ ├── branding-pt-BR.css │ │ ├── branding-ru-RU.css │ │ ├── branding-tr-TR.css │ │ ├── branding-ja-JP.css │ │ ├── branding-zh-TW.css │ │ ├── branding-ko-KR.css │ │ ├── branding-zh-CN.css │ │ ├── branding-Help1.css │ │ └── branding-HelpViewer.css │ ├── toc │ │ ├── 3be7df40-3ecf-4234-87de-6668f8ea296b.xml │ │ ├── 2880ee7b-1719-4d3b-2a3b-c3b2c3561637.xml │ │ ├── 29caa05f-397b-bbf5-aac6-75b68d6e6dfc.xml │ │ ├── 3f0929b8-138a-b2a5-1b04-c18fd8cb1df2.xml │ │ ├── 70b34d01-b944-5ad9-35bb-a59d5a6163ad.xml │ │ ├── 63c82045-093b-c5de-2eb7-b10b552076cc.xml │ │ ├── bdac8c0f-1da2-d42a-a6b3-202e3cc216c2.xml │ │ ├── e4e77eb1-55ed-dde6-8a1c-92c5ab190e18.xml │ │ ├── 245f5477-ece5-2785-8fc5-4e674b01e790.xml │ │ ├── 3afcbb12-571f-4ece-6967-c9b70c04269f.xml │ │ ├── e6c08447-bd14-46cd-e3d7-e950d22f06f9.xml │ │ ├── 15333739-5651-7647-7b1b-5f3556cc8a41.xml │ │ ├── 52c12e18-62d3-5737-59e6-d5ee32c1932d.xml │ │ ├── 162d9fb4-59b9-7e46-6604-07b3e8162612.xml │ │ ├── 19ec9502-ea90-3676-e8b7-92ab521e1cc7.xml │ │ ├── 1c1bc3b1-6a70-aeb8-5424-e645cb500e31.xml │ │ ├── 34fe35cb-867b-8be3-9305-c0d133303dec.xml │ │ ├── 3dee4a96-2455-2e66-b218-25be426ad09e.xml │ │ ├── 46b06974-c769-34aa-1f62-0386c36b7723.xml │ │ ├── 5ab3223c-3291-66f7-1166-af8965e58100.xml │ │ ├── 6f234b49-7dfa-31e9-6d2f-afcaa2ec9b31.xml │ │ ├── 80092fd9-627d-5e8e-2ae1-5ffbffe93a0e.xml │ │ ├── 864600b0-1c13-91b7-adc4-79b56044a8f0.xml │ │ ├── 94a43e2b-74df-3a4e-b3b5-a5676e60815d.xml │ │ ├── a637795d-8b68-9417-8fc8-be587a9bd084.xml │ │ ├── af180185-09a7-9683-8fdd-33271d8f91d9.xml │ │ ├── ba69c671-e94d-c96a-f200-47b07d804b75.xml │ │ ├── ce1318f4-6eb8-b5b9-7c7c-acdeaffc8187.xml │ │ ├── ce982615-ad5c-811d-176e-0c75c25cf8a8.xml │ │ ├── db76990b-8c9e-d0e3-db8e-8093b75813ce.xml │ │ ├── roottoc.xml │ │ ├── 1f0a41c1-6d41-07f4-8ed3-1eb117e47530.xml │ │ ├── 2e0bc207-7576-f53e-9691-78d56f87afa1.xml │ │ ├── 89ff3eb2-c1b8-c00d-ef9b-4c0adcdda15c.xml │ │ ├── 9ae0fa85-2518-8414-0787-9330aa7663db.xml │ │ ├── a42e8331-b602-2717-342c-4a8775e323d2.xml │ │ ├── b8472da8-2a80-64b5-0a89-64c1f6625259.xml │ │ ├── e8300d27-ee7d-c100-ff1a-ef2c159828b1.xml │ │ ├── f33d68a0-8c96-1e26-5cc2-a8a13c3edfcc.xml │ │ ├── 00224bd5-0526-1217-8c56-cc7efc70b703.xml │ │ ├── 5c1108ca-bcfd-cd3e-7472-e9d895660af0.xml │ │ ├── 60f090dd-b01c-df6a-b0ee-838b2d226ba5.xml │ │ ├── 6352aa16-0a65-4bd0-4abe-0af3ca65d740.xml │ │ ├── 72d2b44e-7a54-869b-a423-16336860a564.xml │ │ ├── 86a2f231-6d04-40d4-e311-90eb0f9ef82b.xml │ │ ├── 9d1cde5c-6921-0653-2851-6f6557b58ef8.xml │ │ ├── c15d91ed-dfdd-5b37-578c-e96bdc1b9a61.xml │ │ ├── dc13dc61-4130-e48a-f7f1-789a6f74c0c5.xml │ │ ├── fa5a04ae-b489-8e1b-aa29-eb73361e9202.xml │ │ ├── 3dd61842-7ff7-fa08-5286-617b3c3844b8.xml │ │ ├── 45766ed4-18bf-d207-cdc0-a9471922f489.xml │ │ ├── 513fd17c-ed45-5fdf-06a2-e27025fc932e.xml │ │ ├── 5b4d8fd6-d1cf-b0ff-c26b-db2f9ce0da26.xml │ │ ├── 5be2e229-a731-4cfa-dbcd-7e283d8eab42.xml │ │ ├── b1800b3d-32f4-1603-ca12-23dd3d4db767.xml │ │ ├── b9346cbd-65a6-caf6-ec3e-d0344c8081c7.xml │ │ ├── c237b178-78b8-07f0-f7b0-beb6f32b37d3.xml │ │ ├── c78f0d81-56f9-4e41-70c1-1f4592202895.xml │ │ ├── ce5489fc-f9c7-a044-ca92-8f14099ec5ba.xml │ │ ├── e56e8abb-1d4f-28d5-10ee-89d0e17e8230.xml │ │ ├── 48e33a2f-5d7f-a542-632e-05858d984285.xml │ │ ├── 62f582b6-a886-c77d-141c-0bc3bcb2d03f.xml │ │ ├── 722a9eaa-714e-dc63-245c-3acff5aa72ac.xml │ │ ├── 820246c5-a7d6-e752-0a11-49a0a5cb11a0.xml │ │ ├── 9ed2e9b7-af6c-3020-b5ec-430f88183fab.xml │ │ ├── a313e53c-8986-54d8-575b-8483880a9715.xml │ │ ├── d0aa9e5d-e3f0-4db1-886b-1a283c169632.xml │ │ ├── da4f61a5-5369-21a9-db5a-013a16e99b45.xml │ │ ├── 441bbac2-574a-8b33-bf08-4cb2706220be.xml │ │ ├── e4645eb7-5ba7-282c-4dff-ae12866ad727.xml │ │ ├── 985bff34-28ac-d32b-2d9b-7f061f15829e.xml │ │ ├── d0112f68-c7f1-7c32-6d53-32dafbb6278e.xml │ │ ├── 142c5ac9-15d6-13d2-b86d-d0a359429ae4.xml │ │ ├── 18225cea-ec20-d16f-943d-45943a5b1da0.xml │ │ ├── 1ef3e5fd-f4e8-9017-9e49-21eefec08057.xml │ │ ├── 3528e7ac-ae07-8fcf-c73f-91688a7bee62.xml │ │ ├── 36ae410d-4efa-9101-db43-8412e7c90515.xml │ │ ├── 50036525-3133-5df2-0e7b-9b7fd6fcb3d1.xml │ │ ├── 6de28d25-88e6-02de-13d3-fcc5690a893b.xml │ │ ├── 85b30622-c5fb-4f4a-4505-af8024af92f3.xml │ │ ├── 92b72903-8bc4-5ae1-4a1d-846f016af465.xml │ │ ├── cc7f8431-1d99-e6a6-699d-8c8f73405323.xml │ │ ├── d080a0bd-871a-c400-d4c2-85a86d5c1d8e.xml │ │ ├── d1dbae93-e232-5de8-ec00-154c76f8df22.xml │ │ ├── d8e97374-3e8d-4486-79dd-c8eb6a505f4a.xml │ │ ├── edfc4688-2817-ab3d-5a0e-8be2f4868dab.xml │ │ ├── 0c0f2ca9-67f7-3b12-10ce-4c6be99c9b10.xml │ │ ├── 150b1dd1-81a4-edd9-59b1-37506775fdc7.xml │ │ ├── 1e94de3a-958e-d0f4-872e-f87b4d37b231.xml │ │ ├── 2fe50167-cf46-b0ac-de8d-b1f4b9b2a5b5.xml │ │ ├── 52b10293-f5c4-1351-cd4a-18d89dcfc1bc.xml │ │ ├── cf08b472-5cd6-1d1d-8b77-8dbf44aba6a5.xml │ │ ├── d9bf952b-6aab-3819-cd6d-0abb45e9a3b4.xml │ │ ├── fdeaa71a-0d74-bd2d-648b-1515e849ba61.xml │ │ ├── 08bb6f1a-82ce-460e-51a2-829a32e0706c.xml │ │ ├── a2060c9b-5008-e4ef-4712-48bb033d35f3.xml │ │ ├── b73e3ca3-6b0f-2c88-5443-3580fa8e7de0.xml │ │ ├── 26106450-5672-7b05-bba8-82ca08eba3bb.xml │ │ ├── 435e30d4-1224-fd7c-aec2-50539a7eb199.xml │ │ ├── 6df954dd-2186-0b64-18ee-3d6712759af4.xml │ │ ├── 8938db58-ce66-600b-c5c9-d435d0bf274d.xml │ │ ├── c798d3c4-ec52-5261-84bf-357b9fb2e9cd.xml │ │ ├── ca182566-8e25-2327-5262-db747d59eb2b.xml │ │ ├── d369ef3a-2817-8008-f59b-481f9cbe3136.xml │ │ ├── 9ed69b16-63c3-78f4-b176-cbbe22742679.xml │ │ ├── d3ded3d4-f132-7d83-f18c-cabb8d83ddb4.xml │ │ ├── e7ed7e12-6d05-6ffd-4801-f1d631e88604.xml │ │ ├── f41ac9d6-2bac-e2bf-f623-1c7d07fd2df7.xml │ │ ├── 0e367a0e-5639-d6b9-a48f-1ad716032574.xml │ │ ├── 1a5f2dfc-9eea-fcb0-0bcc-a376bf75020e.xml │ │ ├── b42ec32f-550e-8cf3-95a6-7ea3fe1e664a.xml │ │ ├── bdebb42c-19e7-db32-65b7-533782bcc456.xml │ │ ├── 77a36942-d44a-8144-c402-c3de5359600b.xml │ │ ├── fbd4c044-aac6-51bb-bfa7-9a6a81de0049.xml │ │ ├── 5e9ff647-0bdc-1e67-0d8c-e2181d2f8d91.xml │ │ ├── 643f1a67-bba5-888a-f812-fa39c808dfb1.xml │ │ ├── 95a0f441-9d56-227a-69cc-323a990d2cef.xml │ │ ├── 6994e17c-8bbe-fd1b-9de1-e84e0fa15a31.xml │ │ ├── da973810-ae59-5d87-45d4-14348fa8f948.xml │ │ ├── 2d3745a3-a63a-a7aa-5041-9f601890d6f3.xml │ │ ├── 3e44bfd6-5c15-897b-49b5-d6c9d50f9859.xml │ │ ├── 95ae51a5-a3d2-275f-998e-103bd52a3f73.xml │ │ ├── 020dedca-7a0f-a190-e49a-15ab176feb2c.xml │ │ ├── f60b6857-b98c-ed1e-131f-e17400d1a95c.xml │ │ ├── 164cf225-f899-b74e-aeb9-de2b8f39fdf9.xml │ │ ├── 08f7c35b-31d3-4293-5a43-f74f24cfdd2e.xml │ │ ├── f6ebd0bd-9a1b-fad3-1e62-cc7744bc373f.xml │ │ ├── d1ebbc02-1c0a-d6a8-9fe9-805f855eabda.xml │ │ ├── 70932aa6-5318-f469-2d5a-fb0978b7f195.xml │ │ ├── 66a390b4-59df-0317-f742-c020992602ab.xml │ │ ├── 071f4ef0-c336-33ed-59ee-4c766f00d4be.xml │ │ ├── 7d7550ce-9a02-45e1-f994-4d9494836d7a.xml │ │ ├── 089d0989-3a45-0bce-a9d2-1fac6e903d80.xml │ │ ├── e2e03cc6-a325-1c1c-cae3-2e9056b61560.xml │ │ ├── 7abd601d-6573-a016-2896-0dd717898258.xml │ │ ├── 5cb81c30-5b01-f97c-f07c-88c0c4ec542b.xml │ │ ├── ffab5419-29aa-d7fd-a418-a67fd195f675.xml │ │ ├── aaa34531-49a1-3bbf-e539-4a91b06c133a.xml │ │ ├── 3cc07d55-1e05-34a1-9bc8-28be7c062c25.xml │ │ ├── 13d589d1-e49b-866b-c4c7-4fdf14b7c27a.xml │ │ └── 633616ed-252e-064a-2823-aa491f532248.xml │ ├── index.html │ ├── Web.Config │ ├── search.html │ ├── html │ │ ├── GeneralError.htm │ │ └── PageNotFound.htm │ └── SearchHelp.php └── images │ └── logo.png └── src ├── UniversalTypeConverter ├── UTC.snk ├── logo.png ├── ITypeConverter.cs ├── PropertyResolvingMode.cs ├── Conversions │ ├── IntConversion.cs │ ├── ByteConversion.cs │ ├── UIntConversion.cs │ ├── SByteConversion.cs │ ├── ShortConversion.cs │ ├── ULongConversion.cs │ ├── UShortConversion.cs │ ├── DecimalConversion.cs │ ├── AssignableConversion.cs │ ├── TimeOnlyConversion.cs │ ├── EnumConversion.cs │ ├── GuidConversion.cs │ ├── FormattableConversion.cs │ ├── DateOnlyConversion.cs │ ├── FloatConversion.cs │ ├── TypeConversion.cs │ ├── CharConversion.cs │ ├── DataRowConversion.cs │ ├── DataRecordConversion.cs │ ├── DataRowViewConversion.cs │ ├── DoubleConversion.cs │ ├── TypeConverterConversion.cs │ ├── ConstructorBasedConversion.cs │ ├── ByteArrayConversion.cs │ └── ConversionBase.cs ├── ByteArrayFormat.cs ├── ConversionPriority.cs ├── Reflection │ └── Getter.cs ├── InstantiationException.cs ├── ConstructorResolvingMode.cs ├── IncompatibleDataColumnTypeHandling.cs ├── DateTimeLongMeaning.cs ├── IValueMapping.cs ├── ITypeConversion.cs ├── DataRecordExtension.cs ├── ConversionCollection.cs ├── UniversalTypeConverter.csproj ├── ConversionArgs.cs ├── InvalidConversionException.cs └── UniversalTypeConverter.cs ├── UniversalTypeConverter.Tests ├── UTC.snk ├── SimpleTestEnum.cs ├── FlagsTestEnum.cs ├── UniversalTypeConverter_Tests.cs ├── UniversalTypeConverter.Tests.csproj ├── TypeConverter_Tests.Enumerable.cs ├── UniversalTypeConverter_Tests.Guid.cs ├── TypeConverter_Tests.DataRecord.cs ├── TypeConverter_Tests.Guid.cs ├── TypeConverter_Tests.Enum_Flags.cs.cs ├── DataRecordExtension_Tests.cs ├── TypeConverter_Tests.Formattable.cs ├── TypeConverter_Tests.Assignable.cs ├── TypeConverter_Tests.Int.cs ├── TypeConverter_Tests.Decimal.cs ├── TypeConverter_Tests.Float.cs ├── TypeConverter_Tests.Byte.cs ├── TypeConverter_Tests.UInt.cs ├── TypeConverter_Tests.SByte.cs ├── TypeConverter_Tests.Short.cs ├── TypeConverter_Tests.ULong.cs ├── TypeConverter_Tests.UShort.cs ├── TypeConverter_Tests.Enum.cs ├── TypeConverter_Tests.cs ├── TypeConverter_Tests.TimeOnly.cs ├── TypeConverter_Tests.ByteArray.cs ├── TypeConverter_Tests.Double.cs ├── TypeConverter_Tests.DataRow.cs ├── Compatibility_Tests.cs ├── DictionaryExtension_Tests.cs ├── ConversionResult_Tests.cs ├── TypeConverter_Tests.TryParse.cs ├── TypeConverter_Tests.DateOnly.cs ├── TypeConverter_Tests.ConstructorResolving.cs ├── TypeConverter_Tests.NullHandling.cs └── TypeConverter_Tests.PropertyResolving.cs └── UniversalTypeConverter.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /docs/api/fti/FTI_120.json: -------------------------------------------------------------------------------- 1 | {"xplicitconversion":[2424836,3735558,9568257,10878979,14811137,16187394]} -------------------------------------------------------------------------------- /docs/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/images/logo.png -------------------------------------------------------------------------------- /docs/api/icons/CFW.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/CFW.gif -------------------------------------------------------------------------------- /docs/api/icons/xna.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/xna.gif -------------------------------------------------------------------------------- /docs/api/icons/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/Search.png -------------------------------------------------------------------------------- /docs/api/icons/static.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/static.gif -------------------------------------------------------------------------------- /docs/api/styles/branding-cs-CZ.css: -------------------------------------------------------------------------------- 1 | /* Start CS-CZ locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-de-DE.css: -------------------------------------------------------------------------------- 1 | /* Start DE-DE locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-en-US.css: -------------------------------------------------------------------------------- 1 | /* Start EN-US locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-es-ES.css: -------------------------------------------------------------------------------- 1 | /* Start ES-ES locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-fr-FR.css: -------------------------------------------------------------------------------- 1 | /* Start FR-FR locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-it-IT.css: -------------------------------------------------------------------------------- 1 | /* Start IT-IT locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-pl-PL.css: -------------------------------------------------------------------------------- 1 | /* Start PL-PL locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-pt-BR.css: -------------------------------------------------------------------------------- 1 | /* Start PT-BR locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-ru-RU.css: -------------------------------------------------------------------------------- 1 | /* Start RU-RU locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/styles/branding-tr-TR.css: -------------------------------------------------------------------------------- 1 | /* Start TR-TR locale-specific CSS */ 2 | 3 | /* End locale-specific CSS */ 4 | -------------------------------------------------------------------------------- /docs/api/icons/TocClose.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/TocClose.gif -------------------------------------------------------------------------------- /docs/api/icons/TocOpen.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/TocOpen.gif -------------------------------------------------------------------------------- /docs/api/icons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/favicon.ico -------------------------------------------------------------------------------- /docs/api/icons/pubclass.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubclass.gif -------------------------------------------------------------------------------- /docs/api/icons/pubevent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubevent.gif -------------------------------------------------------------------------------- /docs/api/icons/pubfield.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubfield.gif -------------------------------------------------------------------------------- /docs/api/icons/slMobile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/slMobile.gif -------------------------------------------------------------------------------- /docs/api/icons/AlertNote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/AlertNote.png -------------------------------------------------------------------------------- /docs/api/icons/CodeExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/CodeExample.png -------------------------------------------------------------------------------- /docs/api/icons/TocExpanded.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/TocExpanded.gif -------------------------------------------------------------------------------- /docs/api/icons/privclass.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privclass.gif -------------------------------------------------------------------------------- /docs/api/icons/privevent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privevent.gif -------------------------------------------------------------------------------- /docs/api/icons/privfield.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privfield.gif -------------------------------------------------------------------------------- /docs/api/icons/privmethod.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privmethod.gif -------------------------------------------------------------------------------- /docs/api/icons/protclass.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protclass.gif -------------------------------------------------------------------------------- /docs/api/icons/protevent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protevent.gif -------------------------------------------------------------------------------- /docs/api/icons/protfield.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protfield.gif -------------------------------------------------------------------------------- /docs/api/icons/protmethod.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protmethod.gif -------------------------------------------------------------------------------- /docs/api/icons/pubdelegate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubdelegate.gif -------------------------------------------------------------------------------- /docs/api/icons/pubmethod.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubmethod.gif -------------------------------------------------------------------------------- /docs/api/icons/puboperator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/puboperator.gif -------------------------------------------------------------------------------- /docs/api/icons/pubproperty.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubproperty.gif -------------------------------------------------------------------------------- /docs/api/icons/AlertCaution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/AlertCaution.png -------------------------------------------------------------------------------- /docs/api/icons/AlertSecurity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/AlertSecurity.png -------------------------------------------------------------------------------- /docs/api/icons/TocCollapsed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/TocCollapsed.gif -------------------------------------------------------------------------------- /docs/api/icons/privdelegate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privdelegate.gif -------------------------------------------------------------------------------- /docs/api/icons/privextension.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privextension.gif -------------------------------------------------------------------------------- /docs/api/icons/privinterface.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privinterface.gif -------------------------------------------------------------------------------- /docs/api/icons/privproperty.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privproperty.gif -------------------------------------------------------------------------------- /docs/api/icons/privstructure.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privstructure.gif -------------------------------------------------------------------------------- /docs/api/icons/protdelegate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protdelegate.gif -------------------------------------------------------------------------------- /docs/api/icons/protextension.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protextension.gif -------------------------------------------------------------------------------- /docs/api/icons/protinterface.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protinterface.gif -------------------------------------------------------------------------------- /docs/api/icons/protoperator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protoperator.gif -------------------------------------------------------------------------------- /docs/api/icons/protproperty.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protproperty.gif -------------------------------------------------------------------------------- /docs/api/icons/protstructure.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protstructure.gif -------------------------------------------------------------------------------- /docs/api/icons/pubextension.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubextension.gif -------------------------------------------------------------------------------- /docs/api/icons/pubinterface.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubinterface.gif -------------------------------------------------------------------------------- /docs/api/icons/pubstructure.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubstructure.gif -------------------------------------------------------------------------------- /docs/api/icons/SectionCollapsed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/SectionCollapsed.png -------------------------------------------------------------------------------- /docs/api/icons/SectionExpanded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/SectionExpanded.png -------------------------------------------------------------------------------- /docs/api/icons/privenumeration.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/privenumeration.gif -------------------------------------------------------------------------------- /docs/api/icons/protenumeration.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/protenumeration.gif -------------------------------------------------------------------------------- /docs/api/icons/pubenumeration.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/docs/api/icons/pubenumeration.gif -------------------------------------------------------------------------------- /src/UniversalTypeConverter/UTC.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/src/UniversalTypeConverter/UTC.snk -------------------------------------------------------------------------------- /src/UniversalTypeConverter/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/src/UniversalTypeConverter/logo.png -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/UTC.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-bruning/UniversalTypeConverter/HEAD/src/UniversalTypeConverter.Tests/UTC.snk -------------------------------------------------------------------------------- /docs/api/fti/FTI_119.json: -------------------------------------------------------------------------------- 1 | {"way":[1179649,1572865,7143425,8060929,10682369,15990785],"whos":[1179649,1572865,2490369,7143425,10682369,10813441],"wich":[11468801],"widening":[19136513],"web":[22085633]} -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/SimpleTestEnum.cs: -------------------------------------------------------------------------------- 1 | namespace UniversalTypeConverter.Tests { 2 | 3 | public enum SimpleTestEnum { 4 | Value0 = 0, 5 | Value1 = 1 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/FlagsTestEnum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniversalTypeConverter.Tests { 4 | 5 | [Flags] 6 | public enum FlagsTestEnum { 7 | Value1 = 1, 8 | Value2 = 2, 9 | Value4 = 4 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/UniversalTypeConverter_Tests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace UniversalTypeConverter.Tests { 4 | [TestClass] 5 | public partial class UniversalTypeConverter_Tests { 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /docs/api/toc/3be7df40-3ecf-4234-87de-6668f8ea296b.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/2880ee7b-1719-4d3b-2a3b-c3b2c3561637.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/29caa05f-397b-bbf5-aac6-75b68d6e6dfc.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/3f0929b8-138a-b2a5-1b04-c18fd8cb1df2.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/70b34d01-b944-5ad9-35bb-a59d5a6163ad.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/63c82045-093b-c5de-2eb7-b10b552076cc.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/bdac8c0f-1da2-d42a-a6b3-202e3cc216c2.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/e4e77eb1-55ed-dde6-8a1c-92c5ab190e18.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/245f5477-ece5-2785-8fc5-4e674b01e790.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/3afcbb12-571f-4ece-6967-c9b70c04269f.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/e6c08447-bd14-46cd-e3d7-e950d22f06f9.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/15333739-5651-7647-7b1b-5f3556cc8a41.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/52c12e18-62d3-5737-59e6-d5ee32c1932d.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/162d9fb4-59b9-7e46-6604-07b3e8162612.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/19ec9502-ea90-3676-e8b7-92ab521e1cc7.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/1c1bc3b1-6a70-aeb8-5424-e645cb500e31.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/34fe35cb-867b-8be3-9305-c0d133303dec.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/3dee4a96-2455-2e66-b218-25be426ad09e.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/46b06974-c769-34aa-1f62-0386c36b7723.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/5ab3223c-3291-66f7-1166-af8965e58100.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/6f234b49-7dfa-31e9-6d2f-afcaa2ec9b31.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/80092fd9-627d-5e8e-2ae1-5ffbffe93a0e.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/864600b0-1c13-91b7-adc4-79b56044a8f0.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/94a43e2b-74df-3a4e-b3b5-a5676e60815d.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/a637795d-8b68-9417-8fc8-be587a9bd084.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/af180185-09a7-9683-8fdd-33271d8f91d9.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/ba69c671-e94d-c96a-f200-47b07d804b75.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/ce1318f4-6eb8-b5b9-7c7c-acdeaffc8187.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/ce982615-ad5c-811d-176e-0c75c25cf8a8.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/db76990b-8c9e-d0e3-db8e-8093b75813ce.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/roottoc.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/1f0a41c1-6d41-07f4-8ed3-1eb117e47530.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/2e0bc207-7576-f53e-9691-78d56f87afa1.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/89ff3eb2-c1b8-c00d-ef9b-4c0adcdda15c.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/9ae0fa85-2518-8414-0787-9330aa7663db.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/a42e8331-b602-2717-342c-4a8775e323d2.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/b8472da8-2a80-64b5-0a89-64c1f6625259.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/e8300d27-ee7d-c100-ff1a-ef2c159828b1.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/f33d68a0-8c96-1e26-5cc2-a8a13c3edfcc.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/00224bd5-0526-1217-8c56-cc7efc70b703.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/5c1108ca-bcfd-cd3e-7472-e9d895660af0.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/60f090dd-b01c-df6a-b0ee-838b2d226ba5.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/6352aa16-0a65-4bd0-4abe-0af3ca65d740.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/72d2b44e-7a54-869b-a423-16336860a564.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/86a2f231-6d04-40d4-e311-90eb0f9ef82b.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/9d1cde5c-6921-0653-2851-6f6557b58ef8.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/c15d91ed-dfdd-5b37-578c-e96bdc1b9a61.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/dc13dc61-4130-e48a-f7f1-789a6f74c0c5.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/fa5a04ae-b489-8e1b-aa29-eb73361e9202.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/3dd61842-7ff7-fa08-5286-617b3c3844b8.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/45766ed4-18bf-d207-cdc0-a9471922f489.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/513fd17c-ed45-5fdf-06a2-e27025fc932e.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/5b4d8fd6-d1cf-b0ff-c26b-db2f9ce0da26.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/5be2e229-a731-4cfa-dbcd-7e283d8eab42.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/b1800b3d-32f4-1603-ca12-23dd3d4db767.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/b9346cbd-65a6-caf6-ec3e-d0344c8081c7.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/c237b178-78b8-07f0-f7b0-beb6f32b37d3.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/c78f0d81-56f9-4e41-70c1-1f4592202895.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/ce5489fc-f9c7-a044-ca92-8f14099ec5ba.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/e56e8abb-1d4f-28d5-10ee-89d0e17e8230.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/48e33a2f-5d7f-a542-632e-05858d984285.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/62f582b6-a886-c77d-141c-0bc3bcb2d03f.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/722a9eaa-714e-dc63-245c-3acff5aa72ac.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/820246c5-a7d6-e752-0a11-49a0a5cb11a0.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/9ed2e9b7-af6c-3020-b5ec-430f88183fab.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/a313e53c-8986-54d8-575b-8483880a9715.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d0aa9e5d-e3f0-4db1-886b-1a283c169632.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/da4f61a5-5369-21a9-db5a-013a16e99b45.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/441bbac2-574a-8b33-bf08-4cb2706220be.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/e4645eb7-5ba7-282c-4dff-ae12866ad727.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/985bff34-28ac-d32b-2d9b-7f061f15829e.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d0112f68-c7f1-7c32-6d53-32dafbb6278e.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/142c5ac9-15d6-13d2-b86d-d0a359429ae4.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/18225cea-ec20-d16f-943d-45943a5b1da0.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/1ef3e5fd-f4e8-9017-9e49-21eefec08057.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/3528e7ac-ae07-8fcf-c73f-91688a7bee62.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/36ae410d-4efa-9101-db43-8412e7c90515.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/50036525-3133-5df2-0e7b-9b7fd6fcb3d1.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/6de28d25-88e6-02de-13d3-fcc5690a893b.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/85b30622-c5fb-4f4a-4505-af8024af92f3.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/92b72903-8bc4-5ae1-4a1d-846f016af465.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/cc7f8431-1d99-e6a6-699d-8c8f73405323.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d080a0bd-871a-c400-d4c2-85a86d5c1d8e.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d1dbae93-e232-5de8-ec00-154c76f8df22.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d8e97374-3e8d-4486-79dd-c8eb6a505f4a.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/edfc4688-2817-ab3d-5a0e-8be2f4868dab.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/0c0f2ca9-67f7-3b12-10ce-4c6be99c9b10.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/150b1dd1-81a4-edd9-59b1-37506775fdc7.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/1e94de3a-958e-d0f4-872e-f87b4d37b231.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/2fe50167-cf46-b0ac-de8d-b1f4b9b2a5b5.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/52b10293-f5c4-1351-cd4a-18d89dcfc1bc.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/cf08b472-5cd6-1d1d-8b77-8dbf44aba6a5.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d9bf952b-6aab-3819-cd6d-0abb45e9a3b4.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/fdeaa71a-0d74-bd2d-648b-1515e849ba61.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/08bb6f1a-82ce-460e-51a2-829a32e0706c.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/a2060c9b-5008-e4ef-4712-48bb033d35f3.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/b73e3ca3-6b0f-2c88-5443-3580fa8e7de0.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/26106450-5672-7b05-bba8-82ca08eba3bb.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/435e30d4-1224-fd7c-aec2-50539a7eb199.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/6df954dd-2186-0b64-18ee-3d6712759af4.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/8938db58-ce66-600b-c5c9-d435d0bf274d.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/c798d3c4-ec52-5261-84bf-357b9fb2e9cd.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/ca182566-8e25-2327-5262-db747d59eb2b.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d369ef3a-2817-8008-f59b-481f9cbe3136.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/9ed69b16-63c3-78f4-b176-cbbe22742679.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d3ded3d4-f132-7d83-f18c-cabb8d83ddb4.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/e7ed7e12-6d05-6ffd-4801-f1d631e88604.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/f41ac9d6-2bac-e2bf-f623-1c7d07fd2df7.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/styles/branding-ja-JP.css: -------------------------------------------------------------------------------- 1 | /* Start JA-JP locale-specific CSS */ 2 | body 3 | { 4 | font-family: Segoe UI, Verdana, Arial, MS Pゴシック; 5 | } 6 | pre 7 | { 8 | font-family: Consolas, Courier, monospace, MS ゴシック; 9 | } 10 | span.tt 11 | { 12 | font-family: Consolas, Courier, monospace, MS ゴシック; 13 | } 14 | span.code 15 | { 16 | font-family: Consolas, Courier, monospace, MS ゴシック; 17 | } 18 | /* End locale-specific CSS */ 19 | -------------------------------------------------------------------------------- /docs/api/styles/branding-zh-TW.css: -------------------------------------------------------------------------------- 1 | /* Start ZH-TW locale-specific CSS */ 2 | body 3 | { 4 | font-family: MS JhengHei, MingLiU, Segoe UI, Verdana, Arial; 5 | } 6 | pre 7 | { 8 | font-family: Consolas, Courier, monospace, 細明體; 9 | } 10 | span.tt 11 | { 12 | font-family: Consolas, Courier, monospace, 細明體; 13 | } 14 | span.code 15 | { 16 | font-family: Consolas, Courier, monospace, 細明體; 17 | } 18 | /* End locale-specific CSS */ 19 | -------------------------------------------------------------------------------- /docs/api/toc/0e367a0e-5639-d6b9-a48f-1ad716032574.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/1a5f2dfc-9eea-fcb0-0bcc-a376bf75020e.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/b42ec32f-550e-8cf3-95a6-7ea3fe1e664a.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/bdebb42c-19e7-db32-65b7-533782bcc456.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/77a36942-d44a-8144-c402-c3de5359600b.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/fbd4c044-aac6-51bb-bfa7-9a6a81de0049.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/5e9ff647-0bdc-1e67-0d8c-e2181d2f8d91.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/643f1a67-bba5-888a-f812-fa39c808dfb1.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/95a0f441-9d56-227a-69cc-323a990d2cef.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/styles/branding-ko-KR.css: -------------------------------------------------------------------------------- 1 | /* Start KO-KR locale-specific CSS */ 2 | body 3 | { 4 | font-family: Malgun Gothic, Segoe UI, Verdana, Arial; 5 | font-size: 0.75em; /*9pt*/ 6 | } 7 | pre 8 | { 9 | font-family: Consolas, Courier, monospace, 돋움체; 10 | } 11 | span.tt 12 | { 13 | font-family: Consolas, Courier, monospace, 돋움체; 14 | } 15 | span.code 16 | { 17 | font-family: Consolas, Courier, monospace, 돋움체; 18 | } 19 | /* End locale-specific CSS */ 20 | -------------------------------------------------------------------------------- /docs/api/toc/6994e17c-8bbe-fd1b-9de1-e84e0fa15a31.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/da973810-ae59-5d87-45d4-14348fa8f948.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/2d3745a3-a63a-a7aa-5041-9f601890d6f3.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/3e44bfd6-5c15-897b-49b5-d6c9d50f9859.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/95ae51a5-a3d2-275f-998e-103bd52a3f73.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/styles/branding-zh-CN.css: -------------------------------------------------------------------------------- 1 | /* Start ZH-CN locale-specific CSS */ 2 | body 3 | { 4 | font-family: "Microsoft YaHei UI","Microsoft YaHei","SimSun","Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif 5 | } 6 | pre 7 | { 8 | font-family: Consolas, Courier, monospace!important; 9 | } 10 | span.tt 11 | { 12 | font-family: Consolas, Courier, monospace; 13 | } 14 | span.code 15 | { 16 | font-family: Consolas, Courier, monospace; 17 | } 18 | /* End locale-specific CSS */ 19 | -------------------------------------------------------------------------------- /docs/api/toc/020dedca-7a0f-a190-e49a-15ab176feb2c.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/f60b6857-b98c-ed1e-131f-e17400d1a95c.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/164cf225-f899-b74e-aeb9-de2b8f39fdf9.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/08f7c35b-31d3-4293-5a43-f74f24cfdd2e.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/f6ebd0bd-9a1b-fad3-1e62-cc7744bc373f.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/d1ebbc02-1c0a-d6a8-9fe9-805f855eabda.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/ITypeConverter.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ITypeConverter.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-12 5 | 6 | namespace TB.ComponentModel { 7 | 8 | /// 9 | /// Defines a type converter. 10 | /// 11 | public interface ITypeConverter : ITypeConversion { 12 | 13 | /// 14 | /// Gets the converion options. 15 | /// 16 | IConversionOptions Options { get; } 17 | 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /docs/api/toc/70932aa6-5318-f469-2d5a-fb0978b7f195.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/66a390b4-59df-0317-f742-c020992602ab.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/071f4ef0-c336-33ed-59ee-4c766f00d4be.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/7d7550ce-9a02-45e1-f994-4d9494836d7a.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | UniversalTypeConverter - The Swiss Army Knife for type conversion - Redirect 10 | 11 | 12 |

If you are not redirected automatically, follow this link to the default topic.

13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/api/toc/089d0989-3a45-0bce-a9d2-1fac6e903d80.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/e2e03cc6-a325-1c1c-cae3-2e9056b61560.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/7abd601d-6573-a016-2896-0dd717898258.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/fti/FTI_104.json: -------------------------------------------------------------------------------- 1 | {"high":[13959171],"handled":[1179649,1376260,1572865,7143425,8060929,10158081,10682369,11534339,11730945,15990785,17235969],"hierarchy":[1507329,1572865,2162689,3014657,3145729,3735553,4587521,5242881,5898241,6291457,6422529,6684673,7471105,8454145,9043969,9895937,11665409,11862017,12255233,12451841,12845057,13041665,14483457,14548993,14811137,15728641,16056321,16580609,17694721,17825794,18415617,18677761,19202049,19529729,20512769,20774913,20905985,21168129,21823489,22347777,22413313,22478849,22740993,22872065,23068673,23199745,23265281],"handledbnullasnull":[1179649,1572865,7143425,8060930,10682369,15990787],"hasvalue":[8847361,12386306,14548995,15794177,17956865,19267586,22806529]} -------------------------------------------------------------------------------- /docs/api/toc/5cb81c30-5b01-f97c-f07c-88c0c4ec542b.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/styles/branding-Help1.css: -------------------------------------------------------------------------------- 1 | /* Define the userData cache persistence mechanism for Help 1 files */ 2 | .userDataStyle { 3 | behavior: url(#default#userdata); 4 | } 5 | 6 | /* Style adjustments for Help 1 */ 7 | .pageBody { 8 | padding-top: 0px 20px 0px 0px; 9 | } 10 | 11 | table { 12 | width: 95%; 13 | padding-right: 20px; 14 | } 15 | 16 | table.members { 17 | width: 95%; 18 | padding-right: 20px; 19 | } 20 | 21 | th p { 22 | padding-bottom: 0px; 23 | } 24 | 25 | td p { 26 | padding-bottom: 5px; 27 | } 28 | 29 | .codeSnippetContainerTabs { 30 | top: 1px; 31 | } 32 | 33 | .codeSnippetToolBarText { 34 | top: -13px; 35 | } 36 | 37 | .codeSnippetContainerTabSingle { 38 | padding: 2px 15px 0px 15px; 39 | height: 22px; 40 | } 41 | -------------------------------------------------------------------------------- /docs/api/toc/ffab5419-29aa-d7fd-a418-a67fd195f675.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/styles/branding-HelpViewer.css: -------------------------------------------------------------------------------- 1 | /* Style adjustments for Help Viewer */ 2 | .pageBody { 3 | padding-top: 0px 20px 0px 0px; 4 | } 5 | 6 | table { 7 | width: 95%; 8 | padding-right: 20px; 9 | } 10 | 11 | table.members { 12 | width: 95%; 13 | padding-right: 20px; 14 | } 15 | 16 | th p { 17 | padding-bottom: 0px; 18 | } 19 | 20 | td p { 21 | padding-bottom: 5px; 22 | } 23 | 24 | .codeSnippetContainerTabs { 25 | top: 1px; 26 | } 27 | 28 | .codeSnippetToolBarText { 29 | top: -13px; 30 | } 31 | 32 | .codeSnippetContainerTabSingle { 33 | padding: 2px 15px 0px 15px; 34 | height: 22px; 35 | } 36 | 37 | .codeSnippetContainerTab a:visited { 38 | color: #000000; 39 | } 40 | 41 | .codeSnippetContainerTabActive a:visited { 42 | color: #000000; 43 | } 44 | 45 | span.keyword { 46 | color: #0000ff; 47 | font-weight: normal; 48 | } 49 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/UniversalTypeConverter.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | false 7 | 8 | true 9 | 10 | UTC.snk 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/PropertyResolvingMode.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : PropertyResolvingMode.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-03-06 5 | 6 | namespace TB.ComponentModel { 7 | 8 | /// 9 | /// Defines the mode used when resolving a property by a given type. 10 | /// 11 | public enum PropertyResolvingMode { 12 | 13 | /// 14 | /// No use of property resolving. 15 | /// 16 | None = 0, 17 | 18 | /// 19 | /// A property is used only if it's type is exact of the given type. 20 | /// 21 | Strict, 22 | 23 | /// 24 | /// A property is used if it's type is convertible to the given type. 25 | /// 26 | Lax 27 | 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/IntConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : IntConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for Int's. 12 | /// 13 | public class IntConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(int value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.IntegerFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/ByteConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ByteConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for Bytes. 12 | /// 13 | public class ByteConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(byte value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.IntegerFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/UIntConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : UIntConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for UInt's. 12 | /// 13 | public class UIntConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(uint value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.IntegerFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/SByteConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : SByteConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for SBytes's. 12 | /// 13 | public class SByteConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(sbyte value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.IntegerFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/ShortConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ShortConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for Short's. 12 | /// 13 | public class ShortConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(short value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.IntegerFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/ULongConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ULongConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for ULong's. 12 | /// 13 | public class ULongConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(ulong value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.IntegerFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/UShortConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : UShortConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for UShorts's. 12 | /// 13 | public class UShortConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(ushort value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.IntegerFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/ByteArrayFormat.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ByteArrayFormat.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-16 5 | 6 | namespace TB.ComponentModel { 7 | 8 | /// 9 | /// Defines the format used when converting an array of bytes to its equivalent string representation and vice versa. 10 | /// 11 | public enum ByteArrayFormat { 12 | 13 | /// 14 | /// No format -> no special conversion. 15 | /// 16 | None = 0, 17 | 18 | /// 19 | /// Base64 without line breaks. 20 | /// 21 | Base64, 22 | 23 | /// 24 | /// Base64 with line breaks after every 76 characters in the string representation. 25 | /// 26 | Base64WithLineBreaks 27 | 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/ConversionPriority.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ConversionPriority.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-12 5 | 6 | namespace TB.ComponentModel { 7 | 8 | /// 9 | /// Defines the priority of a conversion. 10 | /// 11 | public enum ConversionPriority { 12 | 13 | /// 14 | /// High priority. 15 | /// Adds a conversion before all other conversions so that the conversion is tried before the built-in conversions. 16 | /// 17 | High = 0, 18 | 19 | /// 20 | /// Low priority. 21 | /// Adds a conversion after all other conversions so that the conversion is tried after all high priority conversions and built-in conversions failed. 22 | /// 23 | Low 24 | 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/DecimalConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DecimalConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for Decimales. 12 | /// 13 | public class DecimalConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(decimal value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.DecimalFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/AssignableConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : AssignableConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-20 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion where the destination type is assignable from the source type. 12 | /// 13 | public class AssignableConversion : ConversionBase { 14 | 15 | /// 16 | public override bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args) { 17 | if (IsAssignable(destinationType, value.GetType())) { 18 | result = value; 19 | return true; 20 | } 21 | 22 | result = null; 23 | return false; 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Enumerable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using FluentAssertions; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using TB.ComponentModel; 6 | 7 | namespace UniversalTypeConverter.Tests { 8 | 9 | partial class TypeConverter_Tests { 10 | 11 | [TestMethod] 12 | public void ConvertToEnumerable_Should_Convert_All_Values_To_The_Given_DestinationType() { 13 | 14 | var values = new List(); 15 | values.Add(true); 16 | values.Add("11"); 17 | values.Add(111); 18 | 19 | 20 | var result = new TypeConverter().ConvertToEnumerable(values, typeof(int)).ToArray(); 21 | result.Length.Should().Be(3); 22 | result[0].Should().Be(1); 23 | result[1].Should().Be(11); 24 | result[2].Should().Be(111); 25 | 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/TimeOnlyConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DateTimeConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2022-05-14 5 | 6 | #if NET6_0_OR_GREATER 7 | 8 | using System; 9 | 10 | namespace TB.ComponentModel.Conversions { 11 | 12 | /// 13 | /// Defines a conversion for TimeOnly. 14 | /// 15 | public class TimeOnlyConversion : TypeConversion { 16 | 17 | /// 18 | protected override bool TryConvert(TimeOnly value, Type destinationType, out object result, ConversionArgs args) { 19 | if (destinationType == typeof(string)) { 20 | result = value.ToString(args.Options.TimeOnlyFormat, args.Culture); 21 | return true; 22 | } 23 | 24 | result = null; 25 | return false; 26 | } 27 | } 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/EnumConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : EnumConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-20 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for Enum-types. 12 | /// 13 | public class EnumConversion : ConversionBase { 14 | 15 | /// 16 | public override bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args) { 17 | if (IsEnum(destinationType)) { 18 | try { 19 | result = Enum.ToObject(destinationType, value); 20 | return true; 21 | } catch { 22 | } 23 | } 24 | 25 | result = null; 26 | return false; 27 | } 28 | 29 | 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Reflection/Getter.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : Getter.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-03-20 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Reflection { 9 | 10 | internal abstract class Getter { 11 | 12 | public string Name { get; } 13 | 14 | public Type ValueType { get; } 15 | 16 | protected Getter(string name, Type valueType) { 17 | if (string.IsNullOrWhiteSpace(name)) { 18 | throw new ArgumentOutOfRangeException(nameof(name)); 19 | } 20 | 21 | Name = name; 22 | ValueType = valueType ?? throw new ArgumentNullException(nameof(valueType)); 23 | } 24 | 25 | public abstract object GetValue(object obj); 26 | 27 | /// 28 | public override string ToString() { 29 | return Name; 30 | } 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /docs/api/fti/FTI_108.json: -------------------------------------------------------------------------------- 1 | {"lon":[9568257,11862017],"low":[13959170],"lost":[19136513],"link":[1],"load":[22020097],"long":[1179650,1376261,1572866,3342337,7143426,7667713,8126465,10682370,11862017,16318465,17235969,23134209],"looking":[22085633],"longconversion":[3276804,9568257,11862022,16318466,17825793,18284546,20971523],"lifo":[262145,7471105,12517377,13500417,17235969,18939905,19529729,20512769],"list":[196609,262147,589825,1179649,1572865,1769473,2752513,4063233,4718593,5439489,5832705,7143425,7274497,7405569,7471107,9109505,9175041,9306113,9371649,9502721,10354689,10551297,10682369,10747905,10944513,11075585,11272193,12189697,12517378,12582913,12910593,12976129,13172738,13500418,13565954,14680065,15007745,15073282,15138817,15466497,15400961,15532033,15597569,15925249,16580609,16973825,17039361,17104897,17235972,18284545,18939907,19005442,19529731,20447233,20512771,20578305,20774913,21430273,21889025,21954561],"line":[4325378],"locate":[22085633],"lax":[15204353,19136513],"longer":[22085633]} -------------------------------------------------------------------------------- /src/UniversalTypeConverter/InstantiationException.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : InstantiationException.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-04-09 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel { 9 | 10 | /// 11 | /// The exception that is thrown when the instantiation of an object failed. 12 | /// 13 | public class InstantiationException : Exception { 14 | 15 | /// 16 | /// Initializes a new instance of the InstantiationException class. 17 | /// 18 | /// 19 | /// 20 | public InstantiationException(Type typeToInstantiate, Exception innerException) 21 | : base($"Instantiation of {typeToInstantiate} failed:\n{innerException?.Message ?? "(no details)"}", innerException) { 22 | } 23 | 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/GuidConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : GuidConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-11 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines conversions from guids. 12 | /// 13 | public class GuidConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(Guid value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.GuidFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | if (destinationType == typeof(byte[])) { 23 | result = value.ToByteArray(); 24 | return true; 25 | } 26 | 27 | result = null; 28 | return false; 29 | } 30 | 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/UniversalTypeConverter_Tests.Guid.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | 5 | namespace UniversalTypeConverter.Tests { 6 | public partial class UniversalTypeConverter_Tests { 7 | 8 | [TestMethod] 9 | public void Convert_A_Guid_To_String_And_Back_Should_Convert() { 10 | var guid = Guid.NewGuid(); 11 | var guidString = TB.ComponentModel.UniversalTypeConverter.Instance.ConvertTo(guid); 12 | TB.ComponentModel.UniversalTypeConverter.Instance.ConvertTo(guidString).Should().Be(guid); 13 | } 14 | 15 | [TestMethod] 16 | public void Convert_An_Empty_Guid_To_String_And_Back_Should_Convert() { 17 | var guid = Guid.Empty; 18 | var guidString = TB.ComponentModel.UniversalTypeConverter.Instance.ConvertTo(guid); 19 | TB.ComponentModel.UniversalTypeConverter.Instance.ConvertTo(guidString).Should().Be(guid); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/ConstructorResolvingMode.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ConstructorResolvingMode.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-18 5 | 6 | namespace TB.ComponentModel { 7 | 8 | /// 9 | /// Defines the mode used when resolving a constructor by a given parameter type. 10 | /// 11 | public enum ConstructorResolvingMode { 12 | 13 | /// 14 | /// No use of constructor resolving. 15 | /// 16 | None = 0, 17 | 18 | /// 19 | /// A constructor is used only if it's parameter is exact of the given type. 20 | /// 21 | Strict, 22 | 23 | /// 24 | /// A constructor is used if it's parameter is compatible to the the given type an no data is lost. 25 | /// An example of a widening conversion is converting a value that is a 32-bit signed integer to a value that is a 64-bit signed integer. 26 | /// 27 | Lax 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/FormattableConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : FormattableConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-03-06 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for source values which implement . 12 | /// 13 | public class FormattableConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(IFormattable value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType != typeof(string)) { 18 | result = null; 19 | return false; 20 | } 21 | 22 | try { 23 | result = value.ToString(null, args.Culture); 24 | return true; 25 | } catch { 26 | } 27 | 28 | result = null; 29 | return false; 30 | } 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.DataRecord.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using FluentAssertions; 8 | using Microsoft.VisualStudio.TestTools.UnitTesting; 9 | using TB.ComponentModel; 10 | 11 | namespace UniversalTypeConverter.Tests 12 | { 13 | 14 | partial class TypeConverter_Tests { 15 | 16 | [TestMethod] 17 | public void Convert_DataRecord_To_T_Should_Create_New_Instance_Of_T() { 18 | var converter = new TypeConverter(); 19 | IDataRecord record = new RecordDummy("Test", 11); 20 | var poco = converter.ConvertTo(record); 21 | poco.F0.Should().Be("Test"); 22 | poco.F1.Should().Be(11); 23 | } 24 | 25 | public class DataRecordPoco { 26 | 27 | public string F0 { get; } 28 | public int F1 { get; set; } 29 | 30 | public DataRecordPoco(string f0) { 31 | F0 = f0; 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/IncompatibleDataColumnTypeHandling.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : IncompatibleDataColumnTypeHandling.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-03-21 5 | 6 | namespace TB.ComponentModel { 7 | 8 | /// 9 | /// Defines how a type is handled if not valid for a DataColumn of a DataTable. 10 | /// 11 | public enum IncompatibleDataColumnTypeHandling { 12 | 13 | /// 14 | /// The type is handled as String. 15 | /// Values are converted to string using the given TypeConverter. If conversion was not successful, ToString() is used at last. 16 | /// 17 | ToString = 0, 18 | 19 | /// 20 | /// The type is handled as String. 21 | /// Values are converted to string using the given TypeConverter. If conversion was not successful, DBNull is used at last. 22 | /// 23 | AsString, 24 | 25 | /// 26 | /// The type is ignored. 27 | /// 28 | Ignore 29 | 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/DateOnlyConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DateTimeConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2022-05-14 5 | 6 | #if NET6_0_OR_GREATER 7 | 8 | using System; 9 | 10 | namespace TB.ComponentModel.Conversions { 11 | 12 | /// 13 | /// Defines a conversion for DateOnly. 14 | /// 15 | public class DateOnlyConversion : TypeConversion { 16 | 17 | /// 18 | protected override bool TryConvert(DateOnly value, Type destinationType, out object result, ConversionArgs args) { 19 | if (destinationType == typeof(string)) { 20 | result = value.ToString(args.Options.DateOnlyFormat, args.Culture); 21 | return true; 22 | } 23 | 24 | if (destinationType == typeof(DateTime)) { 25 | result = value.ToDateTime(args.Options.DateOnlyDefaultTime); 26 | return true; 27 | } 28 | 29 | result = null; 30 | return false; 31 | } 32 | } 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/DateTimeLongMeaning.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DateTimeLongMeaning.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-16 5 | 6 | namespace TB.ComponentModel { 7 | 8 | /// 9 | /// Defines the meaning of a Long value when converting to DateTime. 10 | /// 11 | public enum DateTimeLongMeaning { 12 | 13 | /// 14 | /// No meaning -> no special conversion. 15 | /// 16 | None = 0, 17 | 18 | /// 19 | /// Long values are handled as DateTime.Ticks. 20 | /// 21 | Ticks, 22 | 23 | /// 24 | /// Long values are handled by DateTime.FromBinary(). 25 | /// 26 | Binary, 27 | 28 | /// 29 | /// Long values are handled by DateTime.FromFileTime(). 30 | /// 31 | FileTime, 32 | 33 | /// 34 | /// Long values are handled by DateTime.FromFileTimeUtc(). 35 | /// 36 | FileTimeUtc 37 | 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /docs/api/toc/aaa34531-49a1-3bbf-e539-4a91b06c133a.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/FloatConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : FloatConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-15 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for Floates. 12 | /// 13 | public class FloatConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(float value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.FloatFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | if (destinationType == typeof(char)) { 23 | try { 24 | var i = Convert.ToInt16(value); 25 | result = Convert.ToChar(i); 26 | return true; 27 | } catch { 28 | } 29 | } 30 | 31 | result = null; 32 | return false; 33 | } 34 | 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/IValueMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TB.ComponentModel { 4 | 5 | /// 6 | /// Defines the mapping of specific source values to specific destination values. 7 | /// 8 | public interface IValueMapping { 9 | 10 | /// 11 | /// Get the source type. 12 | /// 13 | Type SourceType { get; } 14 | 15 | /// 16 | /// Gets the destination type. 17 | /// 18 | Type DestinationType { get; } 19 | 20 | /// 21 | /// Maps the specified source value to an instance of the specified destination type. 22 | /// 23 | /// The value to map. 24 | /// The destination type to map to. 25 | /// An instance of the specified destination type if the mapping succeeded. 26 | /// true if the mapping succeeded; otherwise, false. 27 | bool TryMap(object sourceValue, Type destinationType, out object destinationValue); 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Guid.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests { 7 | 8 | partial class TypeConverter_Tests { 9 | 10 | [TestMethod] 11 | public void Convert_Guid_To_String_Should_Use_Given_Format() { 12 | var converter = new TypeConverter(); 13 | var guid = Guid.NewGuid(); 14 | 15 | converter.ConvertTo(guid).Should().Be(guid.ToString()); 16 | 17 | converter.Options.GuidFormat = "N"; 18 | converter.ConvertTo(guid).Should().Be(guid.ToString("N")); 19 | 20 | converter.Options.GuidFormat = "D"; 21 | converter.ConvertTo(guid).Should().Be(guid.ToString("D")); 22 | } 23 | 24 | [TestMethod] 25 | public void Convert_Guid_To_ByteArray_Should_Work() { 26 | var converter = new TypeConverter(); 27 | var guid = Guid.NewGuid(); 28 | var bytes = guid.ToByteArray(); 29 | 30 | converter.ConvertTo(guid).Should().Equal(bytes); 31 | } 32 | 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/TypeConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : TypeConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-19 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion which is source type specific. 12 | /// 13 | /// 14 | public abstract class TypeConversion : ConversionBase { 15 | 16 | /// 17 | public override bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args) { 18 | if (!(value is TSource sourceValue)) { 19 | result = null; 20 | return false; 21 | } 22 | 23 | return TryConvert(sourceValue, destinationType, out result, args); 24 | } 25 | 26 | /// 27 | /// Converts the given value to the given type. 28 | /// A return value indicates whether the operation succeeded. 29 | /// 30 | protected abstract bool TryConvert(TSource value, Type destinationType, out object result, ConversionArgs args); 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /docs/api/toc/3cc07d55-1e05-34a1-9bc8-28be7c062c25.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Enum_Flags.cs.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using TB.ComponentModel; 4 | 5 | namespace UniversalTypeConverter.Tests { 6 | partial class TypeConverter_Tests { 7 | 8 | [TestMethod] 9 | public void ConvertTo_String_From_FlagsEnum_Should_Return_String() { 10 | new TypeConverter().ConvertTo(FlagsTestEnum.Value1 | FlagsTestEnum.Value4).Should().Be("Value1, Value4"); 11 | } 12 | 13 | [TestMethod] 14 | public void ConvertTo_FlagsEnum_From_String_Should_Return_Enum() { 15 | new TypeConverter().ConvertTo("Value1, Value4").Should().Be(FlagsTestEnum.Value1 | FlagsTestEnum.Value4); 16 | } 17 | 18 | [TestMethod] 19 | public void ConvertTo_Int_From_FlagsEnum_Should_Return_Int() { 20 | new TypeConverter().ConvertTo(FlagsTestEnum.Value1 | FlagsTestEnum.Value4).Should().Be(5); 21 | } 22 | 23 | [TestMethod] 24 | public void ConvertTo_FlagsEnum_From_Int_Should_Return_Enum() { 25 | new TypeConverter().ConvertTo(5).Should().Be(FlagsTestEnum.Value1 | FlagsTestEnum.Value4); 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/ITypeConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ITypeConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-12 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel { 9 | 10 | /// 11 | /// Defines a conversion. 12 | /// 13 | public interface ITypeConversion { 14 | 15 | /// 16 | /// Converts the given value to the given type. 17 | /// A return value indicates whether the operation succeeded. 18 | /// 19 | /// The value which is converted. 20 | /// The type to which the given value is converted. 21 | /// An instance of type destinationType whose value is equivalent to the given value if the operation succeeded. 22 | /// Arguments for conversion. 23 | /// true, if was converted successfully; otherwise, false. 24 | bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args); 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/CharConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : CharConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-18 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for Chars. 12 | /// 13 | public class CharConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(char value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(double)) { 18 | try { 19 | var i = Convert.ToInt16(value); 20 | result = Convert.ToDouble(i); 21 | return true; 22 | } catch { 23 | } 24 | } 25 | 26 | if (destinationType == typeof(float)) { 27 | try { 28 | var i = Convert.ToInt16(value); 29 | result = Convert.ToSingle(i); 30 | return true; 31 | } catch { 32 | } 33 | } 34 | 35 | result = null; 36 | return false; 37 | } 38 | 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/DataRecordExtension_Tests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Data; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentAssertions; 7 | using Microsoft.VisualStudio.TestTools.UnitTesting; 8 | using TB.ComponentModel; 9 | 10 | namespace UniversalTypeConverter.Tests 11 | { 12 | [TestClass] 13 | public class DataRecordExtension_Tests { 14 | 15 | [TestMethod] 16 | public void ToDictionary_With_Null_Should_Return_An_Empty_Dictionary() { 17 | IDataRecord record = null; 18 | record.ToDictionary().Count.Should().Be(0); 19 | } 20 | 21 | [TestMethod] 22 | public void ToDictionary_Should_Return_Case_Insensitive_Dictionary() { 23 | var dic = new RecordDummy("a", 1).ToDictionary(); 24 | dic.ContainsKey("F0").Should().BeTrue(); 25 | dic.ContainsKey("f0").Should().BeTrue(); 26 | } 27 | 28 | [TestMethod] 29 | public void ToDictionary_Should_Contain_Fields_of_Record() { 30 | var dic = new RecordDummy("a", 1).ToDictionary(); 31 | dic.Count.Should().Be(2); 32 | dic["F0"].Should().Be("a"); 33 | dic["F1"].Should().Be(1); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/DataRowConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DataRowConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-04-08 5 | 6 | using System; 7 | using System.Data; 8 | 9 | namespace TB.ComponentModel.Conversions { 10 | 11 | /// 12 | /// Defines a conversion for DataRows. 13 | /// 14 | public class DataRowConversion : TypeConversion { 15 | 16 | private readonly TypeConverter mConverter; 17 | 18 | /// 19 | /// Initializes a new instance. 20 | /// 21 | /// 22 | public DataRowConversion(TypeConverter converter) { 23 | mConverter = converter ?? throw new ArgumentNullException(nameof(converter)); 24 | } 25 | 26 | /// 27 | protected override bool TryConvert(DataRow row, Type destinationType, out object result, ConversionArgs args) { 28 | if (row == null) { 29 | result = null; 30 | return false; 31 | } 32 | 33 | var properties = row.ToDictionary(); 34 | return mConverter.TryCreate(destinationType, properties, out result, args.Culture); 35 | } 36 | 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Formattable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using FluentAssertions; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using TB.ComponentModel; 6 | 7 | namespace UniversalTypeConverter.Tests 8 | { 9 | 10 | partial class TypeConverter_Tests { 11 | 12 | [TestMethod] 13 | public void Conversion_Should_Use_IFormattable() { 14 | var converter = new TypeConverter(); 15 | converter.DefaultCulture = new CultureInfo("de-DE"); 16 | 17 | var formattable = new FormattableDummy(); 18 | converter.ConvertTo(formattable).Should().Be("de-DE"); 19 | 20 | converter.DefaultCulture = new CultureInfo("en-US"); 21 | converter.ConvertTo(formattable).Should().Be("en-US"); 22 | } 23 | 24 | private class FormattableDummy : IFormattable { 25 | 26 | /// 27 | public string ToString(string format, IFormatProvider formatProvider) { 28 | if (format != null) { 29 | throw new ArgumentOutOfRangeException(nameof(format), "format should be null"); 30 | } 31 | 32 | return formatProvider.ToString(); 33 | } 34 | 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Assignable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests { 7 | 8 | partial class TypeConverter_Tests { 9 | 10 | [TestMethod] 11 | public void Convert_ToImplemetedInterface_ShouldConvert() { 12 | var value = 1; 13 | var convertible = new TypeConverter().ConvertTo(value); 14 | convertible.Should().Be(value); 15 | } 16 | 17 | [TestMethod] 18 | public void Convert_FromBaseToDerivedClass_ShouldConvert() { 19 | TestClassBase derived = new DerivedTestClass(); 20 | var result = new TypeConverter().ConvertTo(derived); 21 | result.Should().BeSameAs(derived); 22 | } 23 | 24 | [TestMethod] 25 | public void Convert_FromDerivedToBase_ShouldConvert() { 26 | var derived = new DerivedTestClass(); 27 | var result = new TypeConverter().ConvertTo(derived); 28 | result.Should().BeSameAs(derived); 29 | } 30 | 31 | } 32 | 33 | public class TestClassBase { 34 | 35 | } 36 | 37 | public class DerivedTestClass : TestClassBase { 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/DataRecordConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DataRecordConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-04-08 5 | 6 | using System; 7 | using System.Data; 8 | 9 | namespace TB.ComponentModel.Conversions { 10 | 11 | /// 12 | /// Defines a conversion for IDataRecords. 13 | /// 14 | public class DataRecordConversion : TypeConversion { 15 | 16 | private readonly TypeConverter mConverter; 17 | 18 | /// 19 | /// Initializes a new instance. 20 | /// 21 | /// 22 | public DataRecordConversion(TypeConverter converter) { 23 | mConverter = converter ?? throw new ArgumentNullException(nameof(converter)); 24 | } 25 | 26 | /// 27 | protected override bool TryConvert(IDataRecord record, Type destinationType, out object result, ConversionArgs args) { 28 | if (record == null) { 29 | result = null; 30 | return false; 31 | } 32 | 33 | var properties = record.ToDictionary(); 34 | return mConverter.TryCreate(destinationType, properties, out result, args.Culture); 35 | } 36 | 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/DataRowViewConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DataRowViewConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-04-08 5 | 6 | using System; 7 | using System.Data; 8 | 9 | namespace TB.ComponentModel.Conversions { 10 | 11 | /// 12 | /// Defines a conversion for DataRowViews. 13 | /// 14 | public class DataRowViewConversion : TypeConversion { 15 | 16 | private readonly TypeConverter mConverter; 17 | 18 | /// 19 | /// Initializes a new instance. 20 | /// 21 | /// 22 | public DataRowViewConversion(TypeConverter converter) { 23 | mConverter = converter ?? throw new ArgumentNullException(nameof(converter)); 24 | } 25 | 26 | /// 27 | protected override bool TryConvert(DataRowView rowView, Type destinationType, out object result, ConversionArgs args) { 28 | if (rowView == null) { 29 | result = null; 30 | return false; 31 | } 32 | 33 | var properties = rowView.ToDictionary(); 34 | return mConverter.TryCreate(destinationType, properties, out result, args.Culture); 35 | } 36 | 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Int.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests { 7 | 8 | partial class TypeConverter_Tests { 9 | 10 | [TestMethod] 11 | public void Convert_Int_To_String_Should_Use_Given_Format() { 12 | var converter = new TypeConverter(); 13 | int value = 1234; 14 | 15 | converter.ConvertTo(value).Should().Be(value.ToString()); 16 | 17 | converter.Options.IntegerFormat = "N2"; 18 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 19 | } 20 | 21 | [TestMethod] 22 | public void Convert_Int_To_String_Should_Use_The_Given_Culture() { 23 | var converter = new TypeConverter(); 24 | int value = 1234; 25 | 26 | converter.Options.IntegerFormat = "N2"; 27 | converter.DefaultCulture = new CultureInfo("de-DE"); 28 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 29 | 30 | converter.DefaultCulture = new CultureInfo("en-US"); 31 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 32 | } 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Decimal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Text; 5 | using FluentAssertions; 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | using TB.ComponentModel; 8 | 9 | namespace UniversalTypeConverter.Tests 10 | { 11 | 12 | partial class TypeConverter_Tests { 13 | 14 | [TestMethod] 15 | public void Convert_Decimal_To_String_Should_Use_Given_Format() { 16 | var converter = new TypeConverter(); 17 | var dec = 1234.56m; 18 | 19 | converter.ConvertTo(dec).Should().Be(dec.ToString()); 20 | 21 | converter.Options.DecimalFormat = "C"; 22 | converter.ConvertTo(dec).Should().Be(dec.ToString("C")); 23 | } 24 | 25 | [TestMethod] 26 | public void Convert_Decimal_To_String_Should_Use_The_Given_Culture() { 27 | var converter = new TypeConverter(); 28 | var dec = 1234.56m; 29 | 30 | converter.DefaultCulture = new CultureInfo("de-DE"); 31 | converter.ConvertTo(dec).Should().Be(dec.ToString(new CultureInfo("de-DE"))); 32 | 33 | converter.DefaultCulture = new CultureInfo("en-US"); 34 | converter.ConvertTo(dec).Should().Be(dec.ToString(new CultureInfo("en-US"))); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Float.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests { 7 | 8 | partial class TypeConverter_Tests { 9 | 10 | [TestMethod] 11 | public void Convert_Float_To_String_Should_Use_Given_Format() { 12 | var converter = new TypeConverter(); 13 | float value = 1234.56f; 14 | 15 | converter.ConvertTo(value).Should().Be(value.ToString()); 16 | 17 | converter.Options.FloatFormat = "N2"; 18 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 19 | } 20 | 21 | [TestMethod] 22 | public void Convert_Float_To_String_Should_Use_The_Given_Culture() { 23 | var converter = new TypeConverter(); 24 | float value = 1234.56f; 25 | 26 | converter.Options.FloatFormat = "N2"; 27 | converter.DefaultCulture = new CultureInfo("de-DE"); 28 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 29 | 30 | converter.DefaultCulture = new CultureInfo("en-US"); 31 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 32 | } 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /docs/api/Web.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/DoubleConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DoubleConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-11 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for Doubles. 12 | /// 13 | public class DoubleConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(double value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | result = value.ToString(args.Options.IntegerFormat, args.Culture); 19 | return true; 20 | } 21 | 22 | if (destinationType == typeof(DateTime)) { 23 | try { 24 | result = DateTime.FromOADate(value); 25 | return true; 26 | } catch { 27 | } 28 | } 29 | 30 | if (destinationType == typeof(char)) { 31 | try { 32 | var i = Convert.ToInt16(value); 33 | result = Convert.ToChar(i); 34 | return true; 35 | } catch { 36 | } 37 | } 38 | 39 | result = null; 40 | return false; 41 | } 42 | 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Byte.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using FluentAssertions; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | using TB.ComponentModel; 7 | 8 | namespace UniversalTypeConverter.Tests { 9 | 10 | partial class TypeConverter_Tests { 11 | 12 | [TestMethod] 13 | public void Convert_Byte_To_String_Should_Use_Given_Format() { 14 | var converter = new TypeConverter(); 15 | byte value = 123; 16 | 17 | converter.ConvertTo(value).Should().Be(value.ToString()); 18 | 19 | converter.Options.IntegerFormat = "N2"; 20 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 21 | } 22 | 23 | [TestMethod] 24 | public void Convert_Byte_To_String_Should_Use_The_Given_Culture() { 25 | var converter = new TypeConverter(); 26 | byte value = 123; 27 | 28 | converter.Options.IntegerFormat = "N2"; 29 | converter.DefaultCulture = new CultureInfo("de-DE"); 30 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 31 | 32 | converter.DefaultCulture = new CultureInfo("en-US"); 33 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 34 | } 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.UInt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using FluentAssertions; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | using TB.ComponentModel; 7 | 8 | namespace UniversalTypeConverter.Tests { 9 | 10 | partial class TypeConverter_Tests { 11 | 12 | [TestMethod] 13 | public void Convert_UInt_To_String_Should_Use_Given_Format() { 14 | var converter = new TypeConverter(); 15 | uint value = 1234; 16 | 17 | converter.ConvertTo(value).Should().Be(value.ToString()); 18 | 19 | converter.Options.IntegerFormat = "N2"; 20 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 21 | } 22 | 23 | [TestMethod] 24 | public void Convert_UInt_To_String_Should_Use_The_Given_Culture() { 25 | var converter = new TypeConverter(); 26 | uint value = 1234; 27 | 28 | converter.Options.IntegerFormat = "N2"; 29 | converter.DefaultCulture = new CultureInfo("de-DE"); 30 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 31 | 32 | converter.DefaultCulture = new CultureInfo("en-US"); 33 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 34 | } 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /docs/api/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UniversalTypeConverter - The Swiss Army Knife for type conversion - Search 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 |
16 |
17 |
18 |
19 | 20 | 22 |
23 |
24 |    25 | Sort by title 26 |
27 |
28 |
29 |
30 |

31 | Back

32 |
33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.SByte.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using FluentAssertions; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | using TB.ComponentModel; 7 | 8 | namespace UniversalTypeConverter.Tests { 9 | 10 | partial class TypeConverter_Tests { 11 | 12 | [TestMethod] 13 | public void Convert_SByte_To_String_Should_Use_Given_Format() { 14 | var converter = new TypeConverter(); 15 | sbyte value = -45; 16 | 17 | converter.ConvertTo(value).Should().Be(value.ToString()); 18 | 19 | converter.Options.IntegerFormat = "N2"; 20 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 21 | } 22 | 23 | [TestMethod] 24 | public void Convert_SByte_To_String_Should_Use_The_Given_Culture() { 25 | var converter = new TypeConverter(); 26 | sbyte value = -45; 27 | 28 | converter.Options.IntegerFormat = "N2"; 29 | converter.DefaultCulture = new CultureInfo("de-DE"); 30 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 31 | 32 | converter.DefaultCulture = new CultureInfo("en-US"); 33 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 34 | } 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Short.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using FluentAssertions; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | using TB.ComponentModel; 7 | 8 | namespace UniversalTypeConverter.Tests { 9 | 10 | partial class TypeConverter_Tests { 11 | 12 | [TestMethod] 13 | public void Convert_Short_To_String_Should_Use_Given_Format() { 14 | var converter = new TypeConverter(); 15 | short value = -1234; 16 | 17 | converter.ConvertTo(value).Should().Be(value.ToString()); 18 | 19 | converter.Options.IntegerFormat = "N2"; 20 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 21 | } 22 | 23 | [TestMethod] 24 | public void Convert_Short_To_String_Should_Use_The_Given_Culture() { 25 | var converter = new TypeConverter(); 26 | short value = -1234; 27 | 28 | converter.Options.IntegerFormat = "N2"; 29 | converter.DefaultCulture = new CultureInfo("de-DE"); 30 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 31 | 32 | converter.DefaultCulture = new CultureInfo("en-US"); 33 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 34 | } 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.ULong.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using FluentAssertions; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | using TB.ComponentModel; 7 | 8 | namespace UniversalTypeConverter.Tests { 9 | 10 | partial class TypeConverter_Tests { 11 | 12 | [TestMethod] 13 | public void Convert_ULong_To_String_Should_Use_Given_Format() { 14 | var converter = new TypeConverter(); 15 | ulong value = 1234; 16 | 17 | converter.ConvertTo(value).Should().Be(value.ToString()); 18 | 19 | converter.Options.IntegerFormat = "N2"; 20 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 21 | } 22 | 23 | [TestMethod] 24 | public void Convert_ULong_To_String_Should_Use_The_Given_Culture() { 25 | var converter = new TypeConverter(); 26 | ulong value = 1234; 27 | 28 | converter.Options.IntegerFormat = "N2"; 29 | converter.DefaultCulture = new CultureInfo("de-DE"); 30 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 31 | 32 | converter.DefaultCulture = new CultureInfo("en-US"); 33 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 34 | } 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.UShort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using FluentAssertions; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | using TB.ComponentModel; 7 | 8 | namespace UniversalTypeConverter.Tests { 9 | 10 | partial class TypeConverter_Tests { 11 | 12 | [TestMethod] 13 | public void Convert_UShort_To_String_Should_Use_Given_Format() { 14 | var converter = new TypeConverter(); 15 | ushort value = 1234; 16 | 17 | converter.ConvertTo(value).Should().Be(value.ToString()); 18 | 19 | converter.Options.IntegerFormat = "N2"; 20 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 21 | } 22 | 23 | [TestMethod] 24 | public void Convert_UShort_To_String_Should_Use_The_Given_Culture() { 25 | var converter = new TypeConverter(); 26 | ushort value = 1234; 27 | 28 | converter.Options.IntegerFormat = "N2"; 29 | converter.DefaultCulture = new CultureInfo("de-DE"); 30 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 31 | 32 | converter.DefaultCulture = new CultureInfo("en-US"); 33 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 34 | } 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Enum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests { 7 | partial class TypeConverter_Tests { 8 | 9 | [TestMethod] 10 | public void ConvertTo_String_From_Enum_Should_Return_String() { 11 | new TypeConverter().ConvertTo(SimpleTestEnum.Value1).Should().Be("Value1"); 12 | } 13 | 14 | [TestMethod] 15 | public void ConvertTo_Enum_From_String_Should_Return_Enum() { 16 | new TypeConverter().ConvertTo("Value1").Should().Be(SimpleTestEnum.Value1); 17 | } 18 | 19 | [TestMethod] 20 | public void ConvertTo_Int_From_Enum_Should_Return_Int() { 21 | new TypeConverter().ConvertTo(SimpleTestEnum.Value1).Should().Be(1); 22 | } 23 | 24 | [TestMethod] 25 | public void ConvertTo_Enum_From_Int_Should_Return_Enum() { 26 | new TypeConverter().ConvertTo(1).Should().Be(SimpleTestEnum.Value1); 27 | } 28 | 29 | [TestMethod] 30 | public void ConvertTo_Enum_From_Invalid_Value_Should_Throw_InvalidConversionException() { 31 | Action action = () => new TypeConverter().ConvertTo(DateTime.Now); 32 | action.Should().Throw(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests { 7 | 8 | [TestClass] 9 | public partial class TypeConverter_Tests { 10 | 11 | [TestMethod] 12 | public void AllowDefaultValueIfWhitespace_Option_Should_Work_As_Expected() { 13 | var converter = new TypeConverter(); 14 | converter.Options.AllowDefaultValueIfWhitespace.Should().BeFalse(); 15 | 16 | Action action = () => converter.ConvertTo(string.Empty); 17 | action.Should().Throw(); 18 | 19 | converter.Options.AllowDefaultValueIfWhitespace = true; 20 | converter.ConvertTo(string.Empty).Should().Be(0); 21 | } 22 | 23 | [TestMethod] 24 | public void AllowDefaultValueIfNotConvertible_Option_Should_Work_As_Expected() { 25 | var converter = new TypeConverter(); 26 | converter.Options.AllowDefaultValueIfNotConvertible.Should().BeFalse(); 27 | 28 | Action action = () => converter.ConvertTo("a"); 29 | action.Should().Throw(); 30 | 31 | converter.Options.AllowDefaultValueIfNotConvertible = true; 32 | converter.ConvertTo(string.Empty).Should().Be(0); 33 | } 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /docs/api/html/GeneralError.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | General Error 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 |
24 |

We're sorry, a general error has occurred.

25 |

Please try to load the page again. If the error persists, please contact the site administrator.

26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.TimeOnly.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System; 4 | using System.Globalization; 5 | using TB.ComponentModel; 6 | 7 | namespace UniversalTypeConverter.Tests { 8 | partial class TypeConverter_Tests { 9 | 10 | [TestMethod] 11 | public void Convert_TimeOnly_To_String_Should_Use_Given_Format() { 12 | var converter = new TypeConverter(); 13 | var time = TimeOnly.FromDateTime(DateTime.Now); 14 | 15 | converter.ConvertTo(time).Should().Be(time.ToString()); 16 | 17 | converter.Options.TimeOnlyFormat = "T"; 18 | converter.ConvertTo(time).Should().Be(time.ToString("T")); 19 | } 20 | 21 | [TestMethod] 22 | public void Convert_TimeOnly_To_String_Should_Use_The_Given_Culture() { 23 | var converter = new TypeConverter(); 24 | var time = TimeOnly.FromDateTime(DateTime.Now); 25 | 26 | converter.DefaultCulture = new CultureInfo("de-DE"); 27 | converter.ConvertTo(time).Should().Be(time.ToString(new CultureInfo("de-DE"))); 28 | 29 | converter.DefaultCulture = new CultureInfo("en-US"); 30 | converter.ConvertTo(time).Should().Be(time.ToString(new CultureInfo("en-US"))); 31 | 32 | converter.DefaultCulture = new CultureInfo("fi-FI"); 33 | converter.ConvertTo(time).Should().Be(time.ToString(new CultureInfo("fi-FI"))); 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.ByteArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests { 7 | 8 | partial class TypeConverter_Tests { 9 | 10 | [TestMethod] 11 | public void Convert_ByteArray_To_String_Should_Use_Given_ByteArrayFormat() { 12 | var bytes = new byte[] { 12, 123, 0 }; 13 | var converter = new TypeConverter(); 14 | converter.Options.ByteArrayFormat.Should().Be(ByteArrayFormat.Base64); 15 | 16 | converter.Options.ByteArrayFormat = ByteArrayFormat.Base64; 17 | converter.ConvertTo(bytes).Should().Be(Convert.ToBase64String(bytes, Base64FormattingOptions.None)); 18 | 19 | converter.Options.ByteArrayFormat = ByteArrayFormat.Base64WithLineBreaks; 20 | converter.ConvertTo(bytes).Should().Be(Convert.ToBase64String(bytes, Base64FormattingOptions.InsertLineBreaks)); 21 | 22 | converter.Options.ByteArrayFormat = ByteArrayFormat.None; 23 | Action action = () => converter.ConvertTo(bytes); 24 | action.Should().Throw(); 25 | } 26 | 27 | [TestMethod] 28 | public void Convert_ByteArray_To_Guid_Should_Work() { 29 | var guid = Guid.NewGuid(); 30 | var bytes = guid.ToByteArray(); 31 | var converter = new TypeConverter(); 32 | 33 | converter.ConvertTo(bytes).Should().Be(guid); 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/DataRecordExtension.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : DataRecordExtension.cs 3 | // author : Thorsten Bruning 4 | // date : 2019-04-02 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Data; 9 | 10 | namespace TB.ComponentModel { 11 | 12 | /// 13 | /// Provides extension methods for DataRows and DataRowViews. 14 | /// 15 | public static class DataRecordExtension { 16 | 17 | /// 18 | /// Creates a new dictionary whose key value pairs represent the fields of the given IDataRecord together with their values. 19 | /// If the record is null, an empty dictionary is created. 20 | /// 21 | /// The IDataRecord whose fields are added to the new dictionary. 22 | /// 23 | /// A new dictionary which contains the fields of together with their values. 24 | /// If is null, an empty dictionary is returned. 25 | /// 26 | public static Dictionary ToDictionary(this IDataRecord record) { 27 | var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); 28 | if (record == null) { 29 | return dictionary; 30 | } 31 | 32 | for (var i = 0; i < record.FieldCount; i++) { 33 | dictionary.Add(record.GetName(i), record.GetValue(i)); 34 | } 35 | 36 | return dictionary; 37 | } 38 | 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/TypeConverterConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : TypeConverterConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-20 5 | 6 | using System; 7 | using System.ComponentModel; 8 | 9 | namespace TB.ComponentModel.Conversions { 10 | 11 | /// 12 | /// Defines a conversion with associated System.ComponentModel.TypeConverters. 13 | /// 14 | public class TypeConverterConversion : ConversionBase { 15 | 16 | /// 17 | public override bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args) { 18 | System.ComponentModel.TypeConverter converter = TypeDescriptor.GetConverter(destinationType); 19 | if (converter.GetType() != typeof(System.ComponentModel.TypeConverter) && converter.CanConvertFrom(value.GetType())) { 20 | try { 21 | result = converter.ConvertFrom(null, args.Culture, value); 22 | return true; 23 | } 24 | catch { 25 | } 26 | } 27 | 28 | converter = TypeDescriptor.GetConverter(value.GetType()); 29 | if (converter.GetType() != typeof(System.ComponentModel.TypeConverter) && converter.CanConvertTo(destinationType)) { 30 | try { 31 | result = converter.ConvertTo(null, args.Culture, value, destinationType); 32 | return true; 33 | } 34 | catch { 35 | } 36 | } 37 | 38 | result = null; 39 | return false; 40 | } 41 | 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /docs/api/html/PageNotFound.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Page Not Found 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 |
24 |

We're sorry, the page you requested cannot be found.

25 |

The URL might be misspelled or the page you are looking for is no longer available. If you entered 26 | the web address, check that it doesn't contain a typo. You can use the search box at the top of the page to 27 | try and locate the page.

28 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/api/SearchHelp.php: -------------------------------------------------------------------------------- 1 | 14 | Nothing found 15 | $val) 48 | { 49 | $wordDictionary[$ftiWord] = $val; 50 | } 51 | } 52 | } 53 | } 54 | 55 | // Perform the search and return the results as a block of HTML 56 | $results = Search($keywords, $fileList, $wordDictionary, $sortByTitle); 57 | echo $results; 58 | ?> -------------------------------------------------------------------------------- /src/UniversalTypeConverter/ConversionCollection.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ConversionCollection.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-12 5 | 6 | using System; 7 | using System.Collections; 8 | using System.Collections.Generic; 9 | 10 | namespace TB.ComponentModel { 11 | 12 | /// 13 | /// Defines a list of conversions. 14 | /// 15 | public class ConversionCollection : IEnumerable { 16 | 17 | private readonly List mConversions = new List(); 18 | 19 | /// 20 | /// Adds the given conversion with the given priority. 21 | /// 22 | /// Conversion to add. 23 | /// Priority of the conversion to add. 24 | /// This instance as part of a fluent interface. 25 | public ConversionCollection Add(ITypeConversion conversion, ConversionPriority priority) { 26 | if (conversion == null) { 27 | throw new ArgumentNullException(nameof(conversion)); 28 | } 29 | 30 | if (priority == ConversionPriority.High) { 31 | mConversions.Insert(0, conversion); 32 | } else { 33 | mConversions.Add(conversion); 34 | } 35 | 36 | return this; 37 | } 38 | 39 | /// 40 | public IEnumerator GetEnumerator() { 41 | return mConversions.GetEnumerator(); 42 | } 43 | 44 | /// 45 | IEnumerator IEnumerable.GetEnumerator() { 46 | return GetEnumerator(); 47 | } 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.Double.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using FluentAssertions; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using TB.ComponentModel; 6 | 7 | namespace UniversalTypeConverter.Tests { 8 | 9 | partial class TypeConverter_Tests { 10 | 11 | [TestMethod] 12 | public void Convert_Double_To_String_Should_Use_Given_Format() { 13 | var converter = new TypeConverter(); 14 | double value = 1234.56; 15 | 16 | converter.ConvertTo(value).Should().Be(value.ToString()); 17 | 18 | converter.Options.IntegerFormat = "N2"; 19 | converter.ConvertTo(value).Should().Be(value.ToString("N2")); 20 | } 21 | 22 | [TestMethod] 23 | public void Convert_Double_To_String_Should_Use_The_Given_Culture() { 24 | var converter = new TypeConverter(); 25 | double value = 1234.56; 26 | 27 | converter.Options.IntegerFormat = "N2"; 28 | converter.DefaultCulture = new CultureInfo("de-DE"); 29 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("de-DE"))); 30 | 31 | converter.DefaultCulture = new CultureInfo("en-US"); 32 | converter.ConvertTo(value).Should().Be(value.ToString("N2", new CultureInfo("en-US"))); 33 | } 34 | 35 | [TestMethod] 36 | public void Convert_Double_To_DateTime_Should_Return_OADate() { 37 | var converter = new TypeConverter(); 38 | var oaDate = DateTime.Now.ToOADate(); 39 | var dateTime = DateTime.FromOADate(oaDate); 40 | converter.ConvertTo(oaDate).Should().Be(dateTime); 41 | } 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2035 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversalTypeConverter", "UniversalTypeConverter\UniversalTypeConverter.csproj", "{35485075-3FA7-4370-9BC2-1955E273243B}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalTypeConverter.Tests", "UniversalTypeConverter.Tests\UniversalTypeConverter.Tests.csproj", "{026CF6EA-E7AB-4883-9259-550BC7C0E3CD}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {35485075-3FA7-4370-9BC2-1955E273243B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {35485075-3FA7-4370-9BC2-1955E273243B}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {35485075-3FA7-4370-9BC2-1955E273243B}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {35485075-3FA7-4370-9BC2-1955E273243B}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {026CF6EA-E7AB-4883-9259-550BC7C0E3CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {026CF6EA-E7AB-4883-9259-550BC7C0E3CD}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {026CF6EA-E7AB-4883-9259-550BC7C0E3CD}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {026CF6EA-E7AB-4883-9259-550BC7C0E3CD}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D0A9E3D3-9BFD-42E8-95A1-C51DB370CFAC} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/UniversalTypeConverter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0;netstandard2.0 5 | TB.ComponentModel 6 | true 7 | 2.7.1 8 | Thorsten Bruning 9 | 10 | MS-PL 11 | Copyright 2011-2024 by Thorsten Bruning 12 | typeconverter typeconversion typeconverting conversion converting converter convert convertible type types UniversalTypeConverter universal casting 13 | The Swiss Army Knife for type conversion. Convert any type to another compatible type without worrying about which method to use. 14 | Version 2.7.1 supports conversion from Guid to byte[] 15 | true 16 | UTC.snk 17 | https://github.com/t-bruning/UniversalTypeConverter 18 | https://github.com/t-bruning/UniversalTypeConverter 19 | logo.png 20 | https://t-bruning.github.io/UniversalTypeConverter/images/logo.png 21 | True 22 | README.md 23 | UniversalTypeConverter 24 | 25 | 26 | 27 | 28 | True 29 | \ 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/ConstructorBasedConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ConstructorBasedConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-17 5 | 6 | using System; 7 | using System.Linq; 8 | using System.Reflection; 9 | 10 | namespace TB.ComponentModel.Conversions { 11 | 12 | /// 13 | /// Defines a conversion for types which provide a constructor with its only parameter beeing compatible to the value to convert from. 14 | /// 15 | public class ConstructorBasedConversion : ITypeConversion { 16 | 17 | /// 18 | public bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args) { 19 | if (args.Options.ConstructorResolvingMode == ConstructorResolvingMode.None || value == null) { 20 | result = null; 21 | return false; 22 | } 23 | 24 | //TODO zz Perfomance improvement on reflection. 25 | 26 | var sourceType = value.GetType(); 27 | var constructor = destinationType.GetConstructors().FirstOrDefault(c => c.GetParameters().Length == 1 && c.GetParameters()[0].ParameterType == sourceType); 28 | if (constructor == null && args.Options.ConstructorResolvingMode == ConstructorResolvingMode.Lax) { 29 | constructor = destinationType.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new[] {sourceType}, null); 30 | } 31 | 32 | if (constructor != null) { 33 | try { 34 | result = constructor.Invoke(new[] {value}); 35 | return true; 36 | } catch { 37 | } 38 | } 39 | 40 | result = null; 41 | return false; 42 | } 43 | 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/ConversionArgs.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ConversionArgs.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-12 5 | 6 | using System; 7 | using System.Globalization; 8 | 9 | namespace TB.ComponentModel { 10 | 11 | /// 12 | /// Provides arguments for a type conversion. 13 | /// 14 | public class ConversionArgs { 15 | 16 | /// 17 | /// Gets the culture which should be used for conversion. 18 | /// 19 | public CultureInfo Culture { get; } 20 | 21 | /// 22 | /// Gets the who initiated the conversion. 23 | /// 24 | public ITypeConverter Caller { get; } 25 | 26 | /// 27 | /// Gets the . 28 | /// 29 | public IConversionOptions Options => Caller.Options; 30 | 31 | /// 32 | /// Instructs the to ignore any following by continuing with the result of the last call of . 33 | /// If the last call returned false, this means that conversion fails if no fallback option is set. 34 | /// 35 | public bool Break { get; set; } 36 | 37 | /// 38 | /// Initializes a new instance. 39 | /// 40 | /// The who initiated the conversion. 41 | /// The culture which should be used for conversion. 42 | public ConversionArgs(ITypeConverter caller, CultureInfo culture) { 43 | Caller = caller ?? throw new ArgumentNullException(nameof(caller)); 44 | Culture = culture ?? throw new ArgumentNullException(nameof(culture)); 45 | } 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /docs/api/toc/13d589d1-e49b-866b-c4c7-4fdf14b7c27a.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/toc/633616ed-252e-064a-2823-aa491f532248.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/InvalidConversionException.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : InvalidConversionException.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-12 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel { 9 | 10 | /// 11 | /// The exception that is thrown when a conversion is invalid. 12 | /// 13 | public class InvalidConversionException : InvalidOperationException { 14 | 15 | /// 16 | /// Initializes a new instance of the InvalidConversionException class. 17 | /// 18 | public InvalidConversionException(object valueToConvert, Type destinationType) 19 | : base($"'{valueToConvert}' ({valueToConvert?.GetType()}) is not convertible to '{destinationType}'.") { 20 | } 21 | 22 | #if NET6_0_OR_GREATER 23 | /// 24 | /// Initializes a new instance of the InvalidConversionException class. 25 | /// 26 | public InvalidConversionException(ReadOnlySpan valueToConvert, Type destinationType) 27 | : base($"'{valueToConvert}' (ReadOnlySpan) is not convertible to '{destinationType}'.") { 28 | } 29 | 30 | /// 31 | /// Initializes a new instance of the InvalidConversionException class. 32 | /// 33 | public InvalidConversionException(string valueToConvert, Type destinationType) 34 | : base($"'{valueToConvert}' ({valueToConvert?.GetType()}) is not convertible to '{destinationType}'.") { 35 | // Overload with string needed because of compiler error CS0121: 36 | // The call is ambiguous between the following methods or properties: 'InvalidConversionException.InvalidConversionException(object, Type)' and 'InvalidConversionException.InvalidConversionException(ReadOnlySpan, Type)' 37 | } 38 | #endif 39 | 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.DataRow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using FluentAssertions; 8 | using Microsoft.VisualStudio.TestTools.UnitTesting; 9 | using TB.ComponentModel; 10 | 11 | namespace UniversalTypeConverter.Tests 12 | { 13 | 14 | partial class TypeConverter_Tests { 15 | 16 | [TestMethod] 17 | public void Convert_DataRow_To_T_Should_Create_New_Instance_Of_T() { 18 | var converter = new TypeConverter(); 19 | var row = NewDataRow("Test", 11); 20 | var poco = converter.ConvertTo(row); 21 | poco.SValue.Should().Be("Test"); 22 | poco.IValue.Should().Be(11); 23 | } 24 | 25 | [TestMethod] 26 | public void Convert_DataRowView_To_T_Should_Create_New_Instance_Of_T() { 27 | var converter = new TypeConverter(); 28 | var row = NewDataRowView("Test", 11); 29 | var poco = converter.ConvertTo(row); 30 | poco.SValue.Should().Be("Test"); 31 | poco.IValue.Should().Be(11); 32 | } 33 | 34 | private DataRow NewDataRow(string sValue, int iValue) { 35 | var table = new DataTable(); 36 | table.Columns.Add("sValue", typeof(string)); 37 | table.Columns.Add("iValue", typeof(int)); 38 | var row = table.NewRow(); 39 | row[0] = sValue; 40 | row[1] = iValue; 41 | table.Rows.Add(row); 42 | return row; 43 | } 44 | 45 | private DataRowView NewDataRowView(string sValue, int iValue) { 46 | return NewDataRow(sValue, iValue).Table.DefaultView[0]; 47 | } 48 | 49 | private class DataRowPoco { 50 | 51 | public string SValue { get; } 52 | public int IValue { get; set; } 53 | 54 | public DataRowPoco(string sValue) { 55 | SValue = sValue; 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/ByteArrayConversion.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ByteArrayConversion.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-10-16 5 | 6 | using System; 7 | 8 | namespace TB.ComponentModel.Conversions { 9 | 10 | /// 11 | /// Defines a conversion for array of bytes. 12 | /// 13 | public class ByteArrayConversion : TypeConversion { 14 | 15 | /// 16 | protected override bool TryConvert(byte[] value, Type destinationType, out object result, ConversionArgs args) { 17 | if (destinationType == typeof(string)) { 18 | switch (args.Options.ByteArrayFormat) { 19 | case ByteArrayFormat.Base64: 20 | try { 21 | result = Convert.ToBase64String(value, Base64FormattingOptions.None); 22 | return true; 23 | } catch { 24 | result = null; 25 | return false; 26 | } 27 | case ByteArrayFormat.Base64WithLineBreaks: 28 | try { 29 | result = Convert.ToBase64String(value, Base64FormattingOptions.InsertLineBreaks); 30 | return true; 31 | } catch { 32 | result = null; 33 | return false; 34 | } 35 | case ByteArrayFormat.None: 36 | args.Break = true; 37 | result = null; 38 | return false; 39 | } 40 | } 41 | 42 | if (destinationType == typeof(Guid)) { 43 | try { 44 | result = new Guid(value); 45 | return true; 46 | } catch { 47 | result = null; 48 | return false; 49 | } 50 | } 51 | 52 | result = null; 53 | return false; 54 | } 55 | 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/Compatibility_Tests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using FluentAssertions; 8 | using Microsoft.VisualStudio.TestTools.UnitTesting; 9 | using TB.ComponentModel; 10 | 11 | namespace UniversalTypeConverter.Tests { 12 | 13 | [TestClass] 14 | public class Compatibility_Tests { 15 | 16 | [TestMethod] 17 | public void CanConvertToT_Should_Execute() { 18 | "1".CanConvertTo(CultureInfo.InvariantCulture).Should().BeTrue(); 19 | } 20 | 21 | [TestMethod] 22 | public void TryConvertToT_With_Out_Parameter_Should_Execute() { 23 | "1".TryConvertTo(out int result, CultureInfo.InvariantCulture).Should().BeTrue(); 24 | result.Should().Be(1); 25 | } 26 | 27 | [TestMethod] 28 | public void ConvertToT_With_CultureInfo_Should_Execute() { 29 | 1.23M.ConvertTo(CultureInfo.InvariantCulture).Should().Be("1.23"); 30 | } 31 | 32 | [TestMethod] 33 | public void CanConvert_Should_Execute() { 34 | "1".CanConvert(typeof(int)).Should().BeTrue(); 35 | } 36 | 37 | [TestMethod] 38 | public void TryConvert_With_Out_Parameter_Should_Execute() { 39 | "1".TryConvert(typeof(int), out var result).Should().BeTrue(); 40 | result.Should().Be(1); 41 | } 42 | 43 | [TestMethod] 44 | public void Convert_With_CultureInfo_Should_Execute() { 45 | 1.23M.Convert(typeof(string), CultureInfo.InvariantCulture).Should().Be("1.23"); 46 | } 47 | 48 | [TestMethod] 49 | public void ConvertToEnumerableT_With_Enumerable_Should_Execute() { 50 | var input = new object[] {"1", "2"}; 51 | input.ConvertToEnumerable().Count().Should().Be(2); 52 | } 53 | 54 | [TestMethod] 55 | public void ConvertToEnumerable_With_Enumerable_Should_Execute() { 56 | var input = new object[] {"1", "2"}; 57 | input.ConvertToEnumerable(typeof(int)).Count().Should().Be(2); 58 | } 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/DictionaryExtension_Tests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentAssertions; 7 | using Microsoft.VisualStudio.TestTools.UnitTesting; 8 | using TB.ComponentModel; 9 | 10 | namespace UniversalTypeConverter.Tests { 11 | 12 | [TestClass] 13 | public class DictionaryExtension_Tests { 14 | 15 | [TestMethod] 16 | public void CreateT_Should_Create_T() { 17 | var dic = new Dictionary(); 18 | dic.Add("Value1", "V1"); 19 | dic.Add("Value2", "V2"); 20 | var t = dic.Create(); 21 | t.Value1.Should().Be("V1"); 22 | t.Value2.Should().Be("V2"); 23 | } 24 | 25 | [TestMethod] 26 | public void Create_With_Type_Should_Create_Instance_Of_Given_Type() { 27 | var dic = new Dictionary(); 28 | dic.Add("Value1", "V1"); 29 | dic.Add("Value2", "V2"); 30 | var t = dic.Create(typeof(DtoDummy)) as DtoDummy; 31 | t.Value1.Should().Be("V1"); 32 | t.Value2.Should().Be("V2"); 33 | } 34 | 35 | [TestMethod] 36 | public void TryCreateT_Should_Create_T() { 37 | var dic = new Dictionary(); 38 | dic.Add("Value1", "V1"); 39 | dic.Add("Value2", "V2"); 40 | dic.TryCreate(out var t).Should().BeTrue(); 41 | t.Value1.Should().Be("V1"); 42 | t.Value2.Should().Be("V2"); 43 | } 44 | 45 | [TestMethod] 46 | public void TryCreate_With_Type_Should_Create_Instance_Of_Given_Type() { 47 | var dic = new Dictionary(); 48 | dic.Add("Value1", "V1"); 49 | dic.Add("Value2", "V2"); 50 | dic.TryCreate(typeof(DtoDummy), out var t).Should().BeTrue(); 51 | ((DtoDummy) t).Value1.Should().Be("V1"); 52 | ((DtoDummy) t).Value2.Should().Be("V2"); 53 | } 54 | 55 | private class DtoDummy { 56 | 57 | public string Value1 { get; set; } 58 | public string Value2 { get; set; } 59 | 60 | } 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/ConversionResult_Tests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests { 7 | 8 | [TestClass] 9 | public class ConversionResult_Tests { 10 | 11 | [TestMethod] 12 | public void Result_With_Value_Should_Contain_Value() { 13 | var result = new ConversionResult(1); 14 | result.HasValue.Should().BeTrue(); 15 | result.Value.Should().Be(1); 16 | } 17 | 18 | [TestMethod] 19 | public void Result_With_Value_Should_Return_Value_Instead_Of_Default() { 20 | var result = new ConversionResult(1); 21 | result.OrDefault().Should().Be(1); 22 | result.Or(2).Should().Be(1); 23 | } 24 | 25 | [TestMethod] 26 | public void Result_With_Value_Should_Be_Convertible_To_Underlying_Type() { 27 | var result = new ConversionResult(1); 28 | result.To().Should().Be(1); 29 | } 30 | 31 | [TestMethod] 32 | public void Result_Without_Value_Should_Not_Contain_Value() { 33 | var result = new ConversionResult(); 34 | result.HasValue.Should().BeFalse(); 35 | } 36 | 37 | [TestMethod] 38 | public void Result_Without_Value_Should_Throw_InvalidOperationException_On_Value_Access() { 39 | var result = new ConversionResult(); 40 | Action a = () => { 41 | var b = result.Value; 42 | }; 43 | a.Should().Throw(); 44 | } 45 | 46 | [TestMethod] 47 | public void Result_Without_Value_Should_Return_Default() { 48 | var result = new ConversionResult(); 49 | result.OrDefault().Should().Be(0); 50 | result.Or(2).Should().Be(2); 51 | } 52 | 53 | [TestMethod] 54 | public void Result_Without_Value_Should_Not_Be_Convertible_To_Underlying_Type() { 55 | var result = new ConversionResult(); 56 | Action a = () => { 57 | var x = result.To(); 58 | }; 59 | a.Should().Throw(); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.TryParse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FluentAssertions; 7 | using Microsoft.VisualStudio.TestTools.UnitTesting; 8 | using TB.ComponentModel; 9 | 10 | namespace UniversalTypeConverter.Tests 11 | { 12 | 13 | partial class TypeConverter_Tests { 14 | 15 | [TestMethod] 16 | public void TryParse_Should_Prefer_FormatProvider_Overload() { 17 | var converter = new TypeConverter(); 18 | var dummy = converter.ConvertTo("1"); 19 | 20 | dummy.Value.Should().Be("1"); 21 | dummy.FormatProviderUsed.Should().BeTrue(); 22 | } 23 | 24 | [TestMethod] 25 | public void TryParse_Should_Ignore_FormatProvider_As_Fallback() { 26 | var converter = new TypeConverter(); 27 | var dummy = converter.ConvertTo("2"); 28 | 29 | dummy.Value.Should().Be("2"); 30 | } 31 | 32 | public class TryParseDummy { 33 | 34 | public string Value { get; } 35 | 36 | public bool FormatProviderUsed { get; } 37 | 38 | private TryParseDummy(string value, bool formatProviderUsed) { 39 | Value = value; 40 | FormatProviderUsed = formatProviderUsed; 41 | } 42 | 43 | public static bool TryParse(string value, IFormatProvider formatProvider, out TryParseDummy dummy) { 44 | dummy = new TryParseDummy(value, formatProviderUsed: true); 45 | return true; 46 | } 47 | 48 | public static bool TryParse(string value, out TryParseDummy dummy) { 49 | dummy = new TryParseDummy(value, formatProviderUsed: false); 50 | return true; 51 | } 52 | 53 | } 54 | 55 | public class TryParseDummy2 { 56 | 57 | public string Value { get; } 58 | 59 | 60 | private TryParseDummy2(string value) { 61 | Value = value; 62 | } 63 | 64 | public static bool TryParse(string value, out TryParseDummy2 dummy) { 65 | dummy = new TryParseDummy2(value); 66 | return true; 67 | } 68 | 69 | } 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter/UniversalTypeConverter.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : UniversalTypeConverter.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-13 5 | 6 | using System.Globalization; 7 | using System.Runtime.CompilerServices; 8 | 9 | [assembly: InternalsVisibleTo("UniversalTypeConverter.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100af0c32add957055314ccbee44e614656eb37656681e3fc572de6459dd386f682c33437ce0a5d073b089705a40bd9020fc1eda214e3368ff0f126aaa970c68bd0eda23d0b251fd91815155b6859bd069963528aa449a23fe9f7e33123b43f594113197ef02b0ec1fad21622f604340836c5e6f11088961cac0da8e83e73a1bf9d")] 10 | namespace TB.ComponentModel { 11 | 12 | /// 13 | /// Defines the default type converter. 14 | /// 15 | public static class UniversalTypeConverter { 16 | 17 | internal static readonly TypeConverter Instance; 18 | 19 | /// 20 | /// Defines the culture which should be used for conversion by default. 21 | /// Returns if not set or null. 22 | /// 23 | public static CultureInfo DefaultCulture { 24 | get => Instance.DefaultCulture; 25 | set => Instance.DefaultCulture = value; 26 | } 27 | 28 | /// 29 | /// Gets the 30 | /// collection of return values for conversions that convert from null. 31 | /// 32 | public static TypeValueDictionary NullValues => Instance.NullValues; 33 | 34 | /// 35 | /// Gets the list of mappings of specific source values to specific return values. 36 | /// The list is implemented as 'Last In – First Out' (LIFO). 37 | /// 38 | public static ValueMappingCollection ValueMappings => Instance.ValueMappings; 39 | 40 | /// 41 | /// Gets the list of conversions used by this converter. 42 | /// 43 | public static ConversionCollection Conversions => Instance.Conversions; 44 | 45 | /// 46 | /// Gets the conversion options. 47 | /// 48 | public static ConversionOptions Options => Instance.Options; 49 | 50 | static UniversalTypeConverter() { 51 | Instance = new TypeConverter(); 52 | } 53 | 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter/Conversions/ConversionBase.cs: -------------------------------------------------------------------------------- 1 | // project : UniversalTypeConverter 2 | // file : ConversionBase.cs 3 | // author : Thorsten Bruning 4 | // date : 2018-09-22 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Reflection; 9 | using TB.ComponentModel.Reflection; 10 | 11 | namespace TB.ComponentModel.Conversions { 12 | 13 | /// 14 | /// Defines a base class for conversions. 15 | /// 16 | public abstract class ConversionBase : ITypeConversion { 17 | 18 | /// 19 | public abstract bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args); 20 | 21 | /// 22 | /// Determines if the given type is is assignable from another type 23 | /// 24 | /// 25 | /// 26 | /// 27 | protected static bool IsAssignable(Type type, Type fromType) { 28 | return type.GetTypeInfo().IsAssignableFrom(fromType.GetTypeInfo()); 29 | } 30 | 31 | /// 32 | /// Gets the collection of methods for the given type. 33 | /// 34 | /// 35 | /// 36 | protected static IEnumerable GetMethodsOf(Type type) { 37 | return type.GetTypeInfo().DeclaredMethods; 38 | } 39 | 40 | /// 41 | /// Determines if the given type is an Enum. 42 | /// 43 | /// 44 | /// 45 | protected static bool IsEnum(Type type) { 46 | return type.GetTypeInfo().IsEnum; 47 | } 48 | 49 | /// 50 | /// Determines if the given type is an integer type. 51 | /// 52 | /// 53 | /// 54 | protected static bool IsInteger(Type type) { 55 | return type.IsInteger(); 56 | } 57 | 58 | /// 59 | /// Determines if the given type is an float type. 60 | /// 61 | /// 62 | /// 63 | protected static bool IsFloat(Type type) { 64 | return type.IsFloat(); 65 | } 66 | 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.DateOnly.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System; 4 | using System.Globalization; 5 | using TB.ComponentModel; 6 | 7 | namespace UniversalTypeConverter.Tests { 8 | partial class TypeConverter_Tests { 9 | 10 | [TestMethod] 11 | public void Convert_DateOnly_To_String_Should_Use_Given_Format() { 12 | var converter = new TypeConverter(); 13 | var date = DateOnly.FromDateTime(DateTime.Today); 14 | 15 | converter.ConvertTo(date).Should().Be(date.ToString()); 16 | 17 | converter.Options.DateOnlyFormat = "D"; 18 | converter.ConvertTo(date).Should().Be(date.ToString("D")); 19 | } 20 | 21 | [TestMethod] 22 | public void Convert_DateOnly_To_String_Should_Use_The_Given_Culture() { 23 | var converter = new TypeConverter(); 24 | var date = DateOnly.FromDateTime(DateTime.Today); 25 | 26 | converter.DefaultCulture = new CultureInfo("de-DE"); 27 | converter.ConvertTo(date).Should().Be(date.ToString(new CultureInfo("de-DE"))); 28 | 29 | converter.DefaultCulture = new CultureInfo("en-US"); 30 | converter.ConvertTo(date).Should().Be(date.ToString(new CultureInfo("en-US"))); 31 | } 32 | 33 | [TestMethod] 34 | public void Convert_DateOnly_To_DateTime_Should_Work_By_Default_Using_Midnight() { 35 | var converter = new TypeConverter(); 36 | var date = DateOnly.FromDateTime(DateTime.Today); 37 | var dateTime = date.ToDateTime(new TimeOnly(0, 0, 0, 0)); 38 | 39 | converter.ConvertTo(date).Should().Be(dateTime); 40 | } 41 | 42 | [TestMethod] 43 | public void Convert_DateOnly_To_DateTime_Should_Use_The_Given_DateOnlyDefaultTime() { 44 | var converter = new TypeConverter(); 45 | var date = DateOnly.FromDateTime(DateTime.Today); 46 | 47 | converter.Options.DateOnlyDefaultTime = new TimeOnly(12, 0, 0); 48 | converter.ConvertTo(date).Should().Be(date.ToDateTime(new TimeOnly(12, 0, 0))); 49 | 50 | converter.Options.DateOnlyDefaultTime = new TimeOnly(18, 30, 0); 51 | converter.ConvertTo(date).Should().Be(date.ToDateTime(new TimeOnly(18, 30, 0))); 52 | } 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.ConstructorResolving.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FluentAssertions; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | using TB.ComponentModel; 7 | 8 | namespace UniversalTypeConverter.Tests 9 | { 10 | 11 | partial class TypeConverter_Tests { 12 | 13 | [TestMethod] 14 | public void Conversion_Should_Resolve_Constructor_By_Default() { 15 | var converter = new TypeConverter(); 16 | converter.Options.ConstructorResolvingMode.Should().Be(ConstructorResolvingMode.Strict); 17 | converter.ConvertTo(123).MyValue.Should().Be(123); 18 | } 19 | 20 | [TestMethod] 21 | public void Conversion_Should_Not_Resolve_Constructor_If_Not_Allowed() { 22 | var converter = new TypeConverter(); 23 | converter.Options.ConstructorResolvingMode = ConstructorResolvingMode.None; 24 | Action action = () => converter.ConvertTo(123); 25 | action.Should().Throw(); 26 | } 27 | 28 | [TestMethod] 29 | public void ConstructorResolvingMode_Strict_Should_Be_Strict() { 30 | var converter = new TypeConverter(); 31 | converter.Options.ConstructorResolvingMode = ConstructorResolvingMode.Strict; 32 | 33 | converter.ConvertTo(123).MyValue.Should().Be(123); 34 | 35 | byte b = 123; 36 | Action action = () => converter.ConvertTo(b); 37 | action.Should().Throw(); 38 | } 39 | 40 | [TestMethod] 41 | public void ConstructorResolvingMode_Lax_Should_Be_Lax() { 42 | var converter = new TypeConverter(); 43 | converter.Options.ConstructorResolvingMode = ConstructorResolvingMode.Lax; 44 | 45 | converter.ConvertTo(123).MyValue.Should().Be(123); 46 | 47 | byte b = 123; 48 | converter.ConvertTo(b).MyValue.Should().Be(123); 49 | } 50 | 51 | 52 | private class ConstructorResolvingDummy { 53 | 54 | public int MyValue { get; } 55 | 56 | public ConstructorResolvingDummy(int myValue) { 57 | MyValue = myValue; 58 | } 59 | 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.NullHandling.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using FluentAssertions; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using TB.ComponentModel; 6 | 7 | namespace UniversalTypeConverter.Tests { 8 | 9 | partial class TypeConverter_Tests { 10 | 11 | [TestMethod] 12 | public void Conversion_Of_Null_Should_Throw_InvalidConversionException_If_DestinationType_Is_Not_Nullable() { 13 | Action action = () => new TypeConverter().ConvertTo(null); 14 | action.Should().Throw(); 15 | } 16 | 17 | [TestMethod] 18 | public void Conversion_Of_Null_Should_Return_Default_Value_If_Allowed() { 19 | var converter = new TypeConverter(); 20 | converter.Options.AllowDefaultValueIfNull = true; 21 | converter.ConvertTo(null).Should().Be(0); 22 | } 23 | 24 | [TestMethod] 25 | public void Conversion_Should_Return_Null_By_Default() { 26 | var converter = new TypeConverter(); 27 | converter.ConvertTo(null).Should().BeNull(); 28 | } 29 | 30 | [TestMethod] 31 | public void DBNull_Should_Be_Treated_As_Null_By_Default() { 32 | var converter = new TypeConverter(); 33 | converter.ConvertTo(DBNull.Value).Should().BeNull(); 34 | } 35 | 36 | [TestMethod] 37 | public void HandleDBNullAsNull_Option_Should_Be_Respected() { 38 | var converter = new TypeConverter(); 39 | converter.NullValues.Add(1); 40 | converter.ConvertTo(DBNull.Value).Should().Be(1); 41 | 42 | converter.Options.HandleDBNullAsNull = false; 43 | Action a = () => converter.ConvertTo(DBNull.Value); 44 | a.Should().Throw(); 45 | } 46 | 47 | [TestMethod] 48 | public void Conversion_Should_Return_Null_Value_If_Specified() { 49 | var converter = new TypeConverter(); 50 | var nullValue = new NullValue(); 51 | converter.NullValues.Add(".null."); 52 | converter.NullValues.Add(nullValue); 53 | 54 | converter.ConvertTo(null).Should().Be(".null."); 55 | converter.ConvertTo(null).Should().Be(nullValue); 56 | converter.ConvertTo(null).Should().BeNull(); 57 | } 58 | 59 | private class NullValue { 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/UniversalTypeConverter.Tests/TypeConverter_Tests.PropertyResolving.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FluentAssertions; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | using TB.ComponentModel; 5 | 6 | namespace UniversalTypeConverter.Tests 7 | { 8 | 9 | partial class TypeConverter_Tests { 10 | 11 | [TestMethod] 12 | public void Conversion_Should_Resolve_Property_By_Default() { 13 | var converter = new TypeConverter(); 14 | converter.Options.PropertyResolvingMode.Should().Be(PropertyResolvingMode.Strict); 15 | 16 | var dummy = new PropertyResolvingDummy(4711); 17 | converter.ConvertTo(dummy).Should().Be(4711); 18 | 19 | var timeSpan = new TimeSpan(200000); 20 | converter.ConvertTo(timeSpan).Should().Be(200000); 21 | } 22 | 23 | [TestMethod] 24 | public void Conversion_Should_Not_Resolve_Property_If_Not_Allowed() { 25 | var converter = new TypeConverter(); 26 | converter.Options.PropertyResolvingMode = PropertyResolvingMode.None; 27 | 28 | var dummy = new PropertyResolvingDummy(4711); 29 | Action action = () => converter.ConvertTo(dummy); 30 | action.Should().Throw(); 31 | } 32 | 33 | [TestMethod] 34 | public void PropertyResolvingMode_Strict_Should_Be_Strict() { 35 | var converter = new TypeConverter(); 36 | converter.Options.PropertyResolvingMode = PropertyResolvingMode.Strict; 37 | 38 | var dummy = new PropertyResolvingDummy(4711); 39 | converter.ConvertTo(dummy).Should().Be(4711); 40 | 41 | Action action = () => converter.ConvertTo(dummy); 42 | action.Should().Throw(); 43 | } 44 | 45 | [TestMethod] 46 | public void PropertyResolvingMode_Lax_Should_Be_Lax() { 47 | var converter = new TypeConverter(); 48 | converter.Options.PropertyResolvingMode = PropertyResolvingMode.Lax; 49 | 50 | var dummy = new PropertyResolvingDummy(127); 51 | converter.ConvertTo(dummy).Should().Be(127); 52 | 53 | converter.ConvertTo(dummy).Should().Be(127); 54 | } 55 | 56 | 57 | private class PropertyResolvingDummy { 58 | 59 | public int MyValue { get; } 60 | 61 | public PropertyResolvingDummy(int myValue) { 62 | MyValue = myValue; 63 | } 64 | 65 | } 66 | } 67 | } 68 | --------------------------------------------------------------------------------