Skip to content

Commit 945f949

Browse files
author
Jani Giannoudis
committed
model: added json property order
ndepend cleanup updated version to 0.9.0-beta.8
1 parent 93cf220 commit 945f949

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+730
-125
lines changed

Client.Core/Command/CommandAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace PayrollEngine.Client.Command;
66
/// Payroll engine client command attribute.
77
/// </summary>
88
[AttributeUsage(AttributeTargets.Class)]
9-
public class CommandAttribute : Attribute
9+
public sealed class CommandAttribute : Attribute
1010
{
1111
/// <summary>
1212
/// Command name
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace PayrollEngine.Client.Command;
5+
6+
/// <inheritdoc />
7+
public abstract class CommandBase<TArgs> : CommandBase where TArgs : ICommandParameters, new()
8+
{
9+
/// <summary>
10+
/// Execute command.
11+
/// </summary>
12+
/// <param name="context">Command context.</param>
13+
/// <param name="parameters">Command parameters.</param>
14+
/// <returns>Error code, zero on valid command execution.</returns>
15+
protected abstract Task<int> Execute(CommandContext context, TArgs parameters);
16+
17+
/// <summary>
18+
/// Execute command.
19+
/// </summary>
20+
/// <param name="context">Command context.</param>
21+
/// <param name="parameters">Command parameters.</param>
22+
/// <returns>Error code, zero on valid command execution.</returns>
23+
protected override async Task<int> OnExecute(CommandContext context, ICommandParameters parameters)
24+
{
25+
if (context == null)
26+
{
27+
throw new ArgumentNullException(nameof(context));
28+
}
29+
if (parameters == null)
30+
{
31+
throw new ArgumentNullException(nameof(parameters));
32+
}
33+
return await Execute(context, (TArgs)parameters);
34+
}
35+
}

Client.Core/Command/CommandBase.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,35 +98,4 @@ protected static async Task DisplayResponseContent(ICommandConsole console, Http
9898
/// <inheritdoc />
9999
public override string ToString() =>
100100
GetType().Name;
101-
}
102-
103-
/// <inheritdoc />
104-
public abstract class CommandBase<TArgs> : CommandBase where TArgs : ICommandParameters, new()
105-
{
106-
/// <summary>
107-
/// Execute command.
108-
/// </summary>
109-
/// <param name="context">Command context.</param>
110-
/// <param name="parameters">Command parameters.</param>
111-
/// <returns>Error code, zero on valid command execution.</returns>
112-
protected abstract Task<int> Execute(CommandContext context, TArgs parameters);
113-
114-
/// <summary>
115-
/// Execute command.
116-
/// </summary>
117-
/// <param name="context">Command context.</param>
118-
/// <param name="parameters">Command parameters.</param>
119-
/// <returns>Error code, zero on valid command execution.</returns>
120-
protected override async Task<int> OnExecute(CommandContext context, ICommandParameters parameters)
121-
{
122-
if (context == null)
123-
{
124-
throw new ArgumentNullException(nameof(context));
125-
}
126-
if (parameters == null)
127-
{
128-
throw new ArgumentNullException(nameof(parameters));
129-
}
130-
return await Execute(context, (TArgs)parameters);
131-
}
132101
}

Client.Core/Command/CommandLineParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private bool ContainsToggle(string toggleValue)
6060
/// <summary>Determines whether the specified argument is a toggle</summary>
6161
/// <param name="argument">The argument</param>
6262
/// <returns>True if the specified argument exists</returns>
63-
private bool IsToggleArgument(string argument)
63+
private static bool IsToggleArgument(string argument)
6464
{
6565
if (string.IsNullOrWhiteSpace(argument))
6666
{

Client.Core/Command/CommandManager.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public class CommandManager(ICommandConsole console, ILogger logger = null)
2121
/// <summary>
2222
/// Name fo the help command (default: Help)
2323
/// </summary>
24-
private string HelpCommandName => "Help";
24+
private static string HelpCommandName => "Help";
2525

2626
/// <summary>
2727
/// Extension for command files (default: <see cref="FileExtensions.PayrollEngineCommand"/>)
2828
/// </summary>
29-
private string CommandFileExtension => FileExtensions.PayrollEngineCommand;
29+
private static string CommandFileExtension => FileExtensions.PayrollEngineCommand;
3030

3131
/// <summary>
3232
/// Register assembly commands
@@ -239,9 +239,9 @@ private async Task<int> ExecuteAsync(ICommand command, CommandLineParser command
239239

240240
#region Command File
241241

242-
private class FileItem
242+
private sealed class FileItem
243243
{
244-
public FileItem(string text, string path, CommandLineParser parser, List<FileItem> children) :
244+
internal FileItem(string text, string path, CommandLineParser parser, List<FileItem> children) :
245245
this(text, null, parser)
246246
{
247247
Path = path;
@@ -250,7 +250,7 @@ public FileItem(string text, string path, CommandLineParser parser, List<FileIte
250250
}
251251

252252
// ReSharper disable once ConvertToPrimaryConstructor
253-
public FileItem(string text, ICommand command, CommandLineParser parser)
253+
internal FileItem(string text, ICommand command, CommandLineParser parser)
254254
{
255255
Text = text;
256256
Command = command;
@@ -260,8 +260,8 @@ public FileItem(string text, ICommand command, CommandLineParser parser)
260260
// ReSharper disable once UnusedAutoPropertyAccessor.Local
261261
internal string Text { get; }
262262
internal string Path { get; }
263-
public ICommand Command { get; }
264-
public CommandLineParser Parser { get; }
263+
internal ICommand Command { get; }
264+
internal CommandLineParser Parser { get; }
265265
internal List<FileItem> Children { get; } = [];
266266
}
267267

@@ -486,7 +486,7 @@ private static string ParseParameters(CommandLineParser parser, string line)
486486
return line;
487487
}
488488

489-
private bool IsCommandFile(string fileName)
489+
private static bool IsCommandFile(string fileName)
490490
{
491491
if (string.IsNullOrWhiteSpace(fileName) || !File.Exists(fileName))
492492
{

Client.Core/Model/Calendar.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.ComponentModel.DataAnnotations;
3+
using System.Text.Json.Serialization;
34

45
namespace PayrollEngine.Client.Model;
56

@@ -9,59 +10,77 @@ public class Calendar : ModelBase, ICalendar, INameObject
910
/// <summary>The calendar name</summary>
1011
[Required]
1112
[StringLength(128)]
13+
[JsonPropertyOrder(100)]
1214
public string Name { get; set; }
1315

1416
/// <inheritdoc/>
17+
[JsonPropertyOrder(101)]
1518
public Dictionary<string, string> NameLocalizations { get; set; }
1619

1720
/// <inheritdoc/>
1821
[Required]
22+
[JsonPropertyOrder(102)]
1923
public CalendarTimeUnit CycleTimeUnit { get; set; } = CalendarTimeUnit.Year;
2024

2125
/// <inheritdoc/>
2226
[Required]
27+
[JsonPropertyOrder(103)]
2328
public CalendarTimeUnit PeriodTimeUnit { get; set; } = CalendarTimeUnit.CalendarMonth;
2429

2530
/// <inheritdoc/>
31+
[JsonPropertyOrder(104)]
2632
public CalendarTimeMap TimeMap { get; set; } = CalendarTimeMap.Period;
2733

2834
/// <inheritdoc/>
35+
[JsonPropertyOrder(105)]
2936
public Month? FirstMonthOfYear { get; set; } = Month.January;
3037

3138
/// <inheritdoc/>
39+
[JsonPropertyOrder(106)]
3240
public decimal? PeriodDayCount { get; set; }
3341

3442
/// <inheritdoc/>
43+
[JsonPropertyOrder(107)]
3544
public CalendarWeekRule? YearWeekRule { get; set; }
3645

3746
/// <inheritdoc/>
47+
[JsonPropertyOrder(108)]
3848
public DayOfWeek? FirstDayOfWeek { get; set; }
3949

4050
/// <inheritdoc/>
51+
[JsonPropertyOrder(109)]
4152
public CalendarWeekMode WeekMode { get; set; } = CalendarWeekMode.Week;
4253

4354
/// <inheritdoc/>
55+
[JsonPropertyOrder(110)]
4456
public bool WorkMonday { get; set; } = true;
4557

4658
/// <inheritdoc/>
59+
[JsonPropertyOrder(111)]
4760
public bool WorkTuesday { get; set; } = true;
4861

4962
/// <inheritdoc/>
63+
[JsonPropertyOrder(112)]
5064
public bool WorkWednesday { get; set; } = true;
5165

5266
/// <inheritdoc/>
67+
[JsonPropertyOrder(113)]
5368
public bool WorkThursday { get; set; } = true;
5469

5570
/// <inheritdoc/>
71+
[JsonPropertyOrder(114)]
5672
public bool WorkFriday { get; set; } = true;
5773

5874
/// <inheritdoc/>
75+
[JsonPropertyOrder(115)]
5976
public bool WorkSaturday { get; set; }
6077

6178
/// <inheritdoc/>
79+
[JsonPropertyOrder(116)]
6280
public bool WorkSunday { get; set; }
6381

6482
/// <inheritdoc/>
83+
[JsonPropertyOrder(117)]
6584
public Dictionary<string, object> Attributes { get; set; }
6685

6786
/// <summary>Initializes a new instance</summary>

Client.Core/Model/Case.cs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.ComponentModel.DataAnnotations;
3+
using System.Text.Json.Serialization;
34

45
namespace PayrollEngine.Client.Model;
56

@@ -8,85 +9,111 @@ public class Case : ModelBase, ICase, INameObject
89
{
910
/// <inheritdoc/>
1011
[Required]
12+
[JsonPropertyOrder(100)]
1113
public CaseType CaseType { get; set; }
1214

1315
/// <summary>The case name</summary>
1416
[Required]
1517
[StringLength(128)]
18+
[JsonPropertyOrder(101)]
1619
public string Name { get; set; }
1720

1821
/// <inheritdoc/>
22+
[JsonPropertyOrder(102)]
1923
public Dictionary<string, string> NameLocalizations { get; set; }
2024

2125
/// <inheritdoc/>
26+
[JsonPropertyOrder(103)]
2227
public List<string> NameSynonyms { get; set; }
2328

2429
/// <inheritdoc/>
30+
[JsonPropertyOrder(104)]
2531
public string Description { get; set; }
2632

2733
/// <inheritdoc/>
34+
[JsonPropertyOrder(105)]
2835
public Dictionary<string, string> DescriptionLocalizations { get; set; }
2936

3037
/// <inheritdoc/>
38+
[JsonPropertyOrder(106)]
3139
public string DefaultReason { get; set; }
3240

3341
/// <inheritdoc/>
42+
[JsonPropertyOrder(107)]
3443
public Dictionary<string, string> DefaultReasonLocalizations { get; set; }
3544

3645
/// <inheritdoc/>
46+
[JsonPropertyOrder(108)]
3747
public string BaseCase { get; set; }
3848

3949
/// <inheritdoc/>
50+
[JsonPropertyOrder(109)]
4051
public List<CaseFieldReference> BaseCaseFields { get; set; }
4152

4253
/// <inheritdoc/>
54+
[JsonPropertyOrder(110)]
4355
public OverrideType OverrideType { get; set; }
4456

4557
/// <inheritdoc/>
58+
[JsonPropertyOrder(111)]
4659
public CaseCancellationType CancellationType { get; set; }
4760

4861
/// <inheritdoc/>
62+
[JsonPropertyOrder(112)]
4963
public bool Hidden { get; set; }
5064

5165
/// <inheritdoc/>
66+
[JsonPropertyOrder(113)]
5267
public string AvailableExpression { get; set; }
5368

5469
/// <inheritdoc/>
70+
[JsonPropertyOrder(114)]
5571
public string AvailableExpressionFile { get; set; }
5672

5773
/// <inheritdoc/>
74+
[JsonPropertyOrder(115)]
5875
public string BuildExpression { get; set; }
5976

6077
/// <inheritdoc/>
78+
[JsonPropertyOrder(116)]
6179
public string BuildExpressionFile { get; set; }
6280

6381
/// <inheritdoc/>
82+
[JsonPropertyOrder(117)]
6483
public string ValidateExpression { get; set; }
6584

6685
/// <inheritdoc/>
86+
[JsonPropertyOrder(118)]
6787
public string ValidateExpressionFile { get; set; }
6888

6989
/// <inheritdoc/>
70-
public List<string> Lookups { get; set; }
71-
72-
/// <inheritdoc/>
73-
public List<CaseSlot> Slots { get; set; }
74-
75-
/// <inheritdoc/>
90+
[JsonPropertyOrder(119)]
7691
public List<string> AvailableActions { get; set; }
7792

7893
/// <inheritdoc/>
94+
[JsonPropertyOrder(120)]
7995
public List<string> BuildActions { get; set; }
8096

8197
/// <inheritdoc/>
98+
[JsonPropertyOrder(121)]
8299
public List<string> ValidateActions { get; set; }
83100

84101
/// <inheritdoc/>
85-
public Dictionary<string, object> Attributes { get; set; }
102+
[JsonPropertyOrder(122)]
103+
public List<string> Lookups { get; set; }
104+
105+
/// <inheritdoc/>
106+
[JsonPropertyOrder(123)]
107+
public List<CaseSlot> Slots { get; set; }
86108

87109
/// <inheritdoc/>
110+
[JsonPropertyOrder(124)]
88111
public List<string> Clusters { get; set; }
89112

113+
/// <inheritdoc/>
114+
[JsonPropertyOrder(125)]
115+
public Dictionary<string, object> Attributes { get; set; }
116+
90117
/// <summary>Initializes a new instance</summary>
91118
public Case()
92119
{

0 commit comments

Comments
 (0)