-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPiExampleFluent.cs
More file actions
38 lines (37 loc) · 1.3 KB
/
PiExampleFluent.cs
File metadata and controls
38 lines (37 loc) · 1.3 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
//TODO: Replace SwitchCase with new version
// using EasySourceGenerators.Abstractions;
// // ReSharper disable ConvertClosureToMethodGroup
//
// namespace EasySourceGenerators.Examples;
//
// public static partial class PiExampleFluent
// {
// public static partial int GetPiDecimal(int decimalNumber);
//
// [MethodBodyGenerator(nameof(GetPiDecimal))]
// static IMethodBodyGenerator GetPiDecimal_Generator() =>
// Generate.MethodBody()
// .ForMethod().WithReturnType<int>().WithParameter<int>()
// .BodyWithSwitchStatement()
// .ForCases(0, 1, 2, 300, 301, 302, 303).ReturnConstantValue(decimalNumber => SlowMath.CalculatePiDecimal(decimalNumber))
// .ForDefaultCase().UseProvidedBody(decimalNumber => SlowMath.CalculatePiDecimal(decimalNumber));
// }
//
// /*
// This will generate the following method:
//
// public static int GetPiDecimal(int decimalNumber)
// {
// switch (decimalNumber)
// {
// case 0: return 3;
// case 1: return 1;
// case 2: return 4;
// case 300: return 3;
// case 301: return 7;
// case 302: return 2;
// case 303: return 4;
// default: return CalculatePiDecimal(decimalNumber);
// }
// }
// */