-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
FormatterBuilder.cs
39 lines (29 loc) · 1019 Bytes
/
FormatterBuilder.cs
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
31
32
33
34
35
36
37
38
39
using System.Collections.Generic;
using GenHTTP.Api.Infrastructure;
namespace GenHTTP.Modules.Conversion.Formatters
{
public sealed class FormatterBuilder : IBuilder<FormatterRegistry>
{
private readonly List<IFormatter> _Registry = new();
#region Functionality
/// <summary>
/// Adds the given formatter to the registry.
/// </summary>
/// <param name="formatter">The formatter to be added</param>
public FormatterBuilder Add(IFormatter formatter)
{
_Registry.Add(formatter);
return this;
}
public FormatterBuilder Add<T>() where T : IFormatter, new() => Add(new T());
/// <summary>
/// Builds the formatter registry based on the configuration.
/// </summary>
/// <returns>The newly created formatter registry</returns>
public FormatterRegistry Build()
{
return new FormatterRegistry(_Registry);
}
#endregion
}
}