-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathFluentCollectionAttributeInfo.cs
More file actions
57 lines (49 loc) · 1.97 KB
/
FluentCollectionAttributeInfo.cs
File metadata and controls
57 lines (49 loc) · 1.97 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
45
46
47
48
49
50
51
52
53
54
55
56
57
using M31.FluentApi.Generator.Commons;
using M31.FluentApi.Generator.SourceGenerators.AttributeElements;
using Microsoft.CodeAnalysis;
namespace M31.FluentApi.Generator.SourceGenerators.AttributeInfo;
internal record FluentCollectionAttributeInfo : AttributeInfoBase
{
private FluentCollectionAttributeInfo(
int builderStep,
string singularName,
string withItems,
string? withItem,
string? withZeroItems,
LambdaBuilderInfo? lambdaBuilderInfo)
: base(builderStep)
{
SingularName = singularName;
SingularNameInCamelCase = singularName.FirstCharToLower();
WithItems = withItems;
WithItem = withItem;
WithZeroItems = withZeroItems;
LambdaBuilderInfo = lambdaBuilderInfo;
}
internal string SingularName { get; }
internal string SingularNameInCamelCase { get; }
internal string WithItems { get; }
internal string? WithItem { get; }
internal string? WithZeroItems { get; }
internal LambdaBuilderInfo? LambdaBuilderInfo { get; }
internal override string FluentMethodName => WithItems;
internal static FluentCollectionAttributeInfo Create(
AttributeData attributeData,
string memberName,
LambdaBuilderInfo? lambdaBuilderInfo)
{
(int builderStep, string singularName, string withItems, string? withItem, string? withZeroItems) =
attributeData.GetConstructorArguments<int, string, string, string?, string?>();
withItems = NameCreator.CreateName(withItems, memberName, singularName);
if (withItem != null)
{
withItem = NameCreator.CreateName(withItem, memberName, singularName);
}
if (withZeroItems != null)
{
withZeroItems = NameCreator.CreateName(withZeroItems, memberName, singularName);
}
return new FluentCollectionAttributeInfo(
builderStep, singularName, withItems, withItem, withZeroItems, lambdaBuilderInfo);
}
}