/
DataFactoryOptions.cs
65 lines (58 loc) · 2.32 KB
/
DataFactoryOptions.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using ToSic.Eav.Plumbing;
using ToSic.Lib.Coding;
namespace ToSic.Eav.Data.Build;
/// <summary>
/// Options how Entities should be generated from the initial data.
/// </summary>
/// <remarks>
/// Added in v15.x but made public in v16.00
/// </remarks>
[PublicApi]
public class DataFactoryOptions
{
/// <summary>
/// The App-ID which will be assigned to the generated entities.
/// By default it will be `0`
/// </summary>
public int AppId { get; }
/// <summary>
/// The type name to use for a generated Entity.
/// </summary>
public string TypeName { get; }
/// <summary>
/// The field in the data which is the default title.
/// Defaults to `Title` if not set.
/// </summary>
public string TitleField { get; }
/// <summary>
/// Determines if Zero IDs are auto-incremented - default is `true`.
/// </summary>
public bool AutoId { get; }
public int IdSeed { get; }
/// <summary>
/// Main Constructor to create such options.
/// </summary>
/// <param name="original">Optional initial object which would be used as a template when creating the new one.</param>
/// <param name="noParamOrder">see [](xref:NetCode.Conventions.NamedParameters)</param>
/// <param name="appId">Optional AppId to set on each generated Entity</param>
/// <param name="typeName">Optional ContentTypeName to use instead of the default</param>
/// <param name="titleField">Optional Title field to use instead of the default `Title`</param>
/// <param name="autoId">Determines if items with Id 0 should get an automatic ID</param>
/// <param name="idSeed">A root ID seed for numbering the items</param>
public DataFactoryOptions(
DataFactoryOptions original = default,
NoParamOrder noParamOrder = default,
int? appId = default,
string typeName = default,
string titleField = default,
bool? autoId = default,
int? idSeed = default
)
{
AppId = appId ?? original?.AppId ?? 0;
TypeName = typeName ?? original?.TypeName ?? DataConstants.DataFactoryDefaultTypeName;
TitleField = titleField.UseFallbackIfNoValue(original?.TitleField).UseFallbackIfNoValue(Attributes.TitleNiceName);
AutoId = autoId ?? original?.AutoId ?? true;
IdSeed = idSeed ?? original?.IdSeed ?? 1;
}
}