@@ -10,38 +10,72 @@ namespace PolylineAlgorithm;
10
10
using System . Diagnostics . CodeAnalysis ;
11
11
using System . Runtime . InteropServices ;
12
12
13
+ /// <summary>
14
+ /// Represents a readonly encoded polyline string.
15
+ /// </summary>
13
16
[ StructLayout ( LayoutKind . Auto ) ]
14
17
[ DebuggerDisplay ( "Value: {ToString()}, IsEmpty: {IsEmpty}, Length: {Length}" ) ]
15
18
public readonly struct Polyline : IEquatable < Polyline > {
16
19
private readonly ReadOnlyMemory < char > _value ;
17
20
21
+ /// <summary>
22
+ /// Creates a new <see cref="Polyline"/> structure that is empty.
23
+ /// </summary>
18
24
public Polyline ( ) {
19
25
_value = ReadOnlyMemory < char > . Empty ;
20
26
}
21
27
28
+ /// <summary>
29
+ /// Creates a new <see cref="Polyline"/> structure that contains the specified string value.
30
+ /// </summary>
22
31
public Polyline ( string value ) {
23
32
_value = value ? . AsMemory ( ) ?? throw new ArgumentNullException ( nameof ( value ) ) ;
24
33
}
25
34
35
+
36
+ /// <summary>
37
+ /// Creates a new <see cref="Polyline"/> structure that contains the specified Unicode character array.
38
+ /// </summary>
26
39
public Polyline ( char [ ] value ) {
27
40
_value = value ? . AsMemory ( ) ?? throw new ArgumentNullException ( nameof ( value ) ) ;
28
41
}
29
42
43
+
44
+ /// <summary>
45
+ /// Creates a new <see cref="Polyline"/> structure that contains the specified readonly memory region.
46
+ /// </summary>
30
47
public Polyline ( ReadOnlyMemory < char > value ) {
31
48
_value = value ;
32
49
}
33
50
34
51
internal readonly ReadOnlySpan < char > Span => _value . Span ;
35
52
53
+ /// <summary>
54
+ /// Gets a value indicating whether this <see cref="Polyline" /> is empty.
55
+ /// </summary>
36
56
public readonly bool IsEmpty => _value . IsEmpty ;
37
57
58
+ /// <summary>
59
+ /// Gets the number of characters in the current <see cref="Polyline" /> object.
60
+ /// </summary>
38
61
public readonly int Length => _value . Length ;
39
62
63
+ /// <summary>
64
+ /// Copies the characters in this instance to a Unicode character array.
65
+ /// </summary>
66
+ /// <returns>A Unicode character array.</returns>
40
67
public char [ ] ToCharArray ( ) => _value . ToArray ( ) ;
41
68
69
+ /// <summary>
70
+ /// Returns underlying <see cref="ReadOnlyMemory{T}" /> this instance represents.
71
+ /// </summary>
72
+ /// <returns></returns>
42
73
public ReadOnlyMemory < char > AsMemory ( ) => _value ;
43
74
44
- /// <inheritdoc />
75
+ /// <summary>
76
+ /// Returns a string representation of the value of this instance.
77
+ /// </summary>
78
+ /// <returns>The string value of this <see cref="Polyline"/> object.</returns>
45
79
public override string ToString ( ) => _value . ToString ( ) ;
46
80
47
81
#region Overrides
@@ -64,35 +98,76 @@ public Polyline(ReadOnlyMemory<char> value) {
64
98
#endregion
65
99
66
100
#region Equality operators
67
-
101
+ /// <summary>
102
+ /// Indicates whether the values of two specified <see cref="Polyline" /> objects are equal.
103
+ /// </summary>
104
+ /// <param name="left">The first object to compare.</param>
105
+ /// <param name="right">The second object to compare.</param>
106
+ /// <returns><see langword="true"/> if <paramref name="left"/> and <paramref name="right"/> are equal; otherwise, <see langword="false"/>.</returns>
68
107
[ ExcludeFromCodeCoverage ]
69
108
public static bool operator == ( Polyline left , Polyline right ) => left . Equals ( right ) ;
70
109
110
+ /// <summary>
111
+ /// Indicates whether the values of two specified <see cref="Polyline" /> objects are not equal.
112
+ /// </summary>
113
+ /// <param name="left">The first object to compare.</param>
114
+ /// <param name="right">The second object to compare.</param>
115
+ /// <returns><see langword="true"/> if <paramref name="left"/> and <paramref name="right"/> are not equal; otherwise, <see langword="false"/>.</returns>
71
116
[ ExcludeFromCodeCoverage ]
72
117
public static bool operator != ( Polyline left , Polyline right ) => ! ( left == right ) ;
73
118
74
119
#endregion
75
120
76
121
#region Factory methods
77
122
123
+ /// <summary>
124
+ /// Creates an instance of the current type from a Unicode character array.
125
+ /// </summary>
126
+ /// <param name="polyline">A Unicode character array representing an encoded polyline.</param>
127
+ /// <returns>The <see cref="Polyline"/> value that corresponds to the specified Unicide character array.</returns>
78
128
public static Polyline FromCharArray ( char [ ] polyline ) => new ( polyline ) ;
79
129
130
+ /// <summary>
131
+ /// Creates an instance of the current type from a readonly memory region.
132
+ /// </summary>
133
+ /// <param name="polyline">A readonly memory region representing an encoded polyline.</param>
134
+ /// <returns>The <see cref="Polyline"/> value that corresponds to the specified readonly memory region.</returns>
80
135
public static Polyline FromMemory ( ReadOnlyMemory < char > polyline ) => new ( polyline ) ;
81
136
137
+ /// <summary>
138
+ /// Creates an instance of the current type from a string.
139
+ /// </summary>
140
+ /// <param name="polyline">A string representing an encoded polyline.</param>
141
+ /// <returns>The <see cref="Polyline"/> value that corresponds to the specified string value.</returns>
82
142
public static Polyline FromString ( string polyline ) => new ( polyline ) ;
83
143
84
144
85
145
#endregion
86
146
87
147
#region Explicit conversions
88
148
149
+ /// <summary>
150
+ /// Defines an explicit conversion of a Unicode character array to a <see cref="Polyline"/>.
151
+ /// </summary>
152
+ /// <param name="polyline">The Unicode character array to convert.</param>
153
+ /// <returns>The converted Unicode character array.</returns>
89
154
[ ExcludeFromCodeCoverage ]
90
155
public static explicit operator Polyline ( char [ ] polyline ) => FromCharArray ( polyline ) ;
91
156
157
+ /// <summary>
158
+ /// Defines an explicit conversion of a readonly memory region to a <see cref="Polyline"/>.
159
+ /// </summary>
160
+ /// <param name="polyline">The readonly memory region to convert.</param>
161
+ /// <returns>The converted readonly memory region.</returns>
92
162
[ SuppressMessage ( "Usage" , "CA2225:Operator overloads have named alternates" , Justification = $ "Provided alternative { nameof ( Polyline ) } .{ nameof ( FromMemory ) } to follow { nameof ( String ) } .{ nameof ( AsMemory ) } naming pattern.") ]
93
163
[ ExcludeFromCodeCoverage ]
94
164
public static explicit operator Polyline ( ReadOnlyMemory < char > polyline ) => FromMemory ( polyline ) ;
95
165
166
+ /// <summary>
167
+ /// Defines an explicit conversion of a string to a <see cref="Polyline"/>.
168
+ /// </summary>
169
+ /// <param name="polyline">The string to convert.</param>
170
+ /// <returns>The converted string.</returns>
96
171
[ ExcludeFromCodeCoverage ]
97
172
public static explicit operator Polyline ( string polyline ) => FromString ( polyline ) ;
98
173
0 commit comments