@@ -7,60 +7,52 @@ namespace Asp.Versioning;
77/// </summary>
88public class DeprecationPolicy
99{
10- private readonly LinkList links ;
10+ private LinkList ? links ;
11+
12+ /// <summary>
13+ /// Gets a read-only list of links that provide information about the deprecation policy.
14+ /// </summary>
15+ /// <value>A read-only list of HTTP links.</value>
16+ /// <remarks>If a link is provided, generally only one link is necessary; however, additional
17+ /// links might be provided for different languages or different formats such as a HTML page
18+ /// or a JSON file.</remarks>
19+ public IList < LinkHeaderValue > Links => links ??= new ( "deprecation" ) ;
20+
21+ /// <summary>
22+ /// Gets a value indicating whether the deprecation policy has any associated links.
23+ /// </summary>
24+ /// <value>True if the deprecation policy has associated links; otherwise, false.</value>
25+ public bool HasLinks => links is not null && links . Count > 0 ;
26+
27+ /// <summary>
28+ /// Gets the date and time when the API version will be deprecated.
29+ /// </summary>
30+ /// <value>The date and time when the API version will be deprecated, if any.</value>
31+ public DateTimeOffset ? Date { get ; }
1132
1233 /// <summary>
1334 /// Initializes a new instance of the <see cref="DeprecationPolicy"/> class.
1435 /// </summary>
15- public DeprecationPolicy ( )
16- {
17- links = new LinkList ( "deprecation" ) ;
18- }
36+ public DeprecationPolicy ( ) { }
1937
2038 /// <summary>
2139 /// Initializes a new instance of the <see cref="DeprecationPolicy"/> class.
2240 /// </summary>
2341 /// <param name="date">The date and time when the API version will be deprecated.</param>
2442 /// <param name="link">The optional link which provides information about the deprecation policy.</param>
2543 public DeprecationPolicy ( DateTimeOffset date , LinkHeaderValue ? link = default )
26- : this ( )
2744 {
2845 Date = date ;
2946
3047 if ( link is not null )
3148 {
32- links . Add ( link ) ;
49+ Links . Add ( link ) ;
3350 }
3451 }
3552
3653 /// <summary>
3754 /// Initializes a new instance of the <see cref="DeprecationPolicy"/> class.
3855 /// </summary>
3956 /// <param name="link">The link which provides information about the deprecation policy.</param>
40- public DeprecationPolicy ( LinkHeaderValue link )
41- : this ( )
42- {
43- links . Add ( link ) ;
44- }
45-
46- /// <summary>
47- /// Gets the date and time when the API version will be deprecated.
48- /// </summary>
49- /// <value>The date and time when the API version will be deprecated, if any.</value>
50- public DateTimeOffset ? Date { get ; }
51-
52- /// <summary>
53- /// Gets a value indicating whether the deprecation policy has any associated links.
54- /// </summary>
55- /// <value>True if the deprecation policy has associated links; otherwise, false.</value>
56- public bool HasLinks => links . Count > 0 ;
57-
58- /// <summary>
59- /// Gets a read-only list of links that provide information about the deprecation policy.
60- /// </summary>
61- /// <value>A read-only list of HTTP links.</value>
62- /// <remarks>If a link is provided, generally only one link is necessary; however, additional
63- /// links might be provided for different languages or different formats such as a HTML page
64- /// or a JSON file.</remarks>
65- public IList < LinkHeaderValue > Links => links ;
57+ public DeprecationPolicy ( LinkHeaderValue link ) => Links . Add ( link ) ;
6658}
0 commit comments