From 8bfbf9d26d0406aaacfbef57eb83732363196368 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Sat, 21 Dec 2024 04:55:28 -0300 Subject: [PATCH] Remove section on TValue customization This is for now an advanced corner use case. --- readme.md | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/readme.md b/readme.md index 83b14d9..6b7fad5 100644 --- a/readme.md +++ b/readme.md @@ -233,39 +233,6 @@ Things to note at template expansion time: by anoother generator. -You can also customize code generation for the `TValue`s used in your struct ids. -For example, the support for automatically registering a generic `Dapper.SqlMapper.TypeHandler` -when a `TValue` implements both `IParsable` and `IFormattable` is implemented as a -so-called `TValue` template: - -```csharp -[TValue] -file class TValue_TypeHandler : Dapper.SqlMapper.TypeHandler -{ - public override TValue Parse(object value) => TValue.Parse((string)value, null); - - public override void SetValue(IDbDataParameter parameter, TValue value) - { - parameter.DbType = DbType.String; - parameter.Value = value.ToString(null, null); - } -} - -file partial struct TValue : IParsable, IFormattable -{ - public static TValue Parse(string s, IFormatProvider? provider) => throw new NotImplementedException(); - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out TValue result) => throw new NotImplementedException(); - public string ToString(string? format, IFormatProvider? formatProvider) => throw new NotImplementedException(); -} -``` - -If you use use [Ulid](https://github.com/Cysharp/Ulid) as a value type in your struct ids, -for example, the template will be applied since `Ulid` implements both `IParsable` and -`IFormattable`. The generated code will look like this: - -```csharp - -