1
1
namespace Schema . NET ;
2
2
3
- using System . Collections . Generic ;
4
3
using System . Linq ;
5
4
using System . Text ;
6
5
@@ -9,6 +8,13 @@ namespace Schema.NET;
9
8
/// </summary>
10
9
public partial class PropertyValueSpecification
11
10
{
11
+ private const string MaxLengthPropertyName = "maxlength=" ;
12
+ private const string MinLengthPropertyName = "minlength=" ;
13
+ private const string NamePropertyName = "name=" ;
14
+ private const string PatternPropertyName = "pattern=" ;
15
+ private const string RequiredPropertyName = "required" ;
16
+ private const char Space = ' ' ;
17
+
12
18
/// <summary>
13
19
/// Returns a <see cref="string" /> that represents the short hand representation of this instance.
14
20
/// See https://schema.org/docs/actions.html#part-3.
@@ -22,35 +28,35 @@ public override string ToString()
22
28
23
29
if ( this . ValueMaxLength . First ( ) is double maxLength )
24
30
{
25
- stringBuilder . Append ( "maxlength=" ) ;
31
+ stringBuilder . Append ( MaxLengthPropertyName ) ;
26
32
stringBuilder . Append ( maxLength ) ;
27
33
}
28
34
29
35
if ( this . ValueMinLength . First ( ) is double minLength )
30
36
{
31
37
AppendSpace ( stringBuilder ) ;
32
- stringBuilder . Append ( "minlength=" ) ;
38
+ stringBuilder . Append ( MinLengthPropertyName ) ;
33
39
stringBuilder . Append ( minLength ) ;
34
40
}
35
41
36
42
if ( this . ValueName . First ( ) is string name )
37
43
{
38
44
AppendSpace ( stringBuilder ) ;
39
- stringBuilder . Append ( "name=" ) ;
45
+ stringBuilder . Append ( NamePropertyName ) ;
40
46
stringBuilder . Append ( name ) ;
41
47
}
42
48
43
49
if ( this . ValuePattern . First ( ) is string pattern )
44
50
{
45
51
AppendSpace ( stringBuilder ) ;
46
- stringBuilder . Append ( "pattern=" ) ;
52
+ stringBuilder . Append ( PatternPropertyName ) ;
47
53
stringBuilder . Append ( pattern ) ;
48
54
}
49
55
50
56
if ( this . ValueRequired . First ( ) is true )
51
57
{
52
58
AppendSpace ( stringBuilder ) ;
53
- stringBuilder . Append ( "required" ) ;
59
+ stringBuilder . Append ( RequiredPropertyName ) ;
54
60
}
55
61
56
62
return stringBuilder . ToString ( ) ;
@@ -60,7 +66,7 @@ private static void AppendSpace(StringBuilder stringBuilder)
60
66
{
61
67
if ( stringBuilder . Length > 0 )
62
68
{
63
- stringBuilder . Append ( ' ' ) ;
69
+ stringBuilder . Append ( Space ) ;
64
70
}
65
71
}
66
72
}
0 commit comments