Skip to content

Commit 100167b

Browse files
authored
Update README.md
1 parent edfbd50 commit 100167b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ app.Endpoints(e => e.MapImageWizard("/image"));
228228

229229
## Create custom filter
230230

231+
- add ImageWizard.Generator package to project
231232
- add a public method which is marked with the filter attribute
232233
- at url level are the following types possible for method overloading:
233234
- integer ("0")
@@ -259,6 +260,21 @@ app.Endpoints(e => e.MapImageWizard("/image"));
259260
}
260261
```
261262

263+
The source generator creates the following code:
264+
265+
```csharp
266+
public partial class BackgroundColorFilter : IFilterFactory
267+
{
268+
public static IEnumerable<IFilterAction> Create()
269+
{
270+
return [
271+
new FilterAction<BackgroundColorFilter>("backgroundcolor", new Regex(@"^\((?<r>-?\d+),(?<g>-?\d+),(?<b>-?\d+)\)$"), (filter, group) => { byte r = byte.Parse(group["r"].ValueSpan, CultureInfo.InvariantCulture);byte g = byte.Parse(group["g"].ValueSpan, CultureInfo.InvariantCulture);byte b = byte.Parse(group["b"].ValueSpan, CultureInfo.InvariantCulture);filter.BackgroundColor(r,g,b); }),
272+
new FilterAction<BackgroundColorFilter>("backgroundcolor", new Regex(@"^\((?<r>-?\d+\.\d+),(?<g>-?\d+\.\d+),(?<b>-?\d+\.\d+)\)$"), (filter, group) => { float r = float.Parse(group["r"].ValueSpan, CultureInfo.InvariantCulture);float g = float.Parse(group["g"].ValueSpan, CultureInfo.InvariantCulture);float b = float.Parse(group["b"].ValueSpan, CultureInfo.InvariantCulture);filter.BackgroundColor(r,g,b); }),
273+
];
274+
}
275+
}
276+
```
277+
262278
Register filter:
263279

264280
```csharp

0 commit comments

Comments
 (0)