77// File name: Router.cs
88// Repository: https://github.com/sisk-http/core
99
10+ using System . Collections ;
1011using System . Diagnostics . CodeAnalysis ;
1112using System . Net ;
1213using System . Runtime . CompilerServices ;
@@ -26,10 +27,13 @@ public ActionHandler ( Type matchingType, Func<object, HttpResponse> handler ) {
2627
2728
2829namespace Sisk . Core . Routing {
30+
2931 /// <summary>
3032 /// Represents a collection of <see cref="Route"/> and main executor of actions in the <see cref="HttpServer"/>.
3133 /// </summary>
32- public sealed partial class Router {
34+ [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Naming" , "CA1710:Identifiers should not have incorrect suffix" ,
35+ Justification = "Breaking change. Not going forward on this one." ) ]
36+ public sealed partial class Router : IReadOnlyCollection < Route > {
3337 internal sealed record RouterExecutionResult ( HttpResponse ? Response , Route ? Route , RouteMatchResult Result , Exception ? Exception ) ;
3438
3539 internal HttpServer ? parentServer ;
@@ -139,6 +143,9 @@ public Router ( IEnumerable<Route> routes )
139143 }
140144 } ) ;
141145
146+ /// <inheritdoc/>
147+ public int Count => ( ( IReadOnlyCollection < Route > ) _routesList ) . Count ;
148+
142149 /// <summary>
143150 /// Gets all routes defined on this router instance.
144151 /// </summary>
@@ -269,6 +276,15 @@ void CheckForRouteCollisionsCore () {
269276 internal void FreeHttpServer ( ) {
270277 parentServer = null ;
271278 }
279+
280+ /// <inheritdoc/>
281+ public IEnumerator < Route > GetEnumerator ( ) {
282+ return ( ( IEnumerable < Route > ) _routesList ) . GetEnumerator ( ) ;
283+ }
284+
285+ IEnumerator IEnumerable . GetEnumerator ( ) {
286+ return ( ( IEnumerable ) _routesList ) . GetEnumerator ( ) ;
287+ }
272288 }
273289
274290 internal enum RouteMatchResult {
0 commit comments