-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFluentExtensions.cs
More file actions
44 lines (41 loc) · 1.2 KB
/
Copy pathFluentExtensions.cs
File metadata and controls
44 lines (41 loc) · 1.2 KB
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
40
41
42
43
44
namespace TedToolkit.Fluent;
/// <summary>
/// Make the one as fluent.
/// </summary>
public static class FluentExtensions
{
private static FluentOptions _options;
/// <summary>
/// The options.
/// </summary>
public static ref FluentOptions Options => ref _options;
/// <summary>
/// Make this value as a fluent one.
/// <example>
/// Create your own data type.
/// <code>
/// class Point
/// {
/// public double X { get; set; }
/// public double Y { get; set; }
/// public void AddX(double x) => X += x;
/// }
/// </code>
/// And then, us it like this. The api will be auto created.
/// <code>
/// var point = new Point().AsFluent()
/// .WithX(5)
/// .DoAddX(6)
/// .Result;
/// </code>
/// </example>
/// </summary>
/// <param name="value"></param>
/// <param name="type"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static Fluent<T> AsFluent<T>(this T value, FluentType? type = null) where T : notnull
{
return new Fluent<T>(value, type ?? _options.DefaultType);
}
}