Я нашел 4 или 5 примеров "строчных маршрутов" в C #, однако, когда я использую конвертер кода telerik, я получаю кучу ошибок.
А именно, что-то связанное с "extension methods can be defined only in modules."
Есть ли у кого-нибудь хорошие ресурсы о том, как сопоставить маршруты в нижний регистр в VB?
РЕДАКТИРОВАТЬ:
вот пример некоторого преобразованного кода, который дает ошибку
Imports System
Imports System.Web.Mvc
Imports System.Web.Routing
Namespace MyMvcApplication.App.Helpers
Public Class LowercaseRoute
Inherits System.Web.Routing.Route
Public Sub New(ByVal url As String, ByVal routeHandler As IRouteHandler)
MyBase.New(url, routeHandler)
End Sub
Public Sub New(ByVal url As String, ByVal defaults As RouteValueDictionary, ByVal routeHandler As IRouteHandler)
MyBase.New(url, defaults, routeHandler)
End Sub
Public Sub New(ByVal url As String, ByVal defaults As RouteValueDictionary, ByVal constraints As RouteValueDictionary, ByVal routeHandler As IRouteHandler)
MyBase.New(url, defaults, constraints, routeHandler)
End Sub
Public Sub New(ByVal url As String, ByVal defaults As RouteValueDictionary, ByVal constraints As RouteValueDictionary, ByVal dataTokens As RouteValueDictionary, ByVal routeHandler As IRouteHandler)
MyBase.New(url, defaults, constraints, dataTokens, routeHandler)
End Sub
Public Overrides Function GetVirtualPath(ByVal requestContext As RequestContext, ByVal values As RouteValueDictionary) As VirtualPathData
Dim path As VirtualPathData = MyBase.GetVirtualPath(requestContext, values)
If path IsNot Nothing Then
path.VirtualPath = path.VirtualPath.ToLowerInvariant()
End If
Return path
End Function
End Class
Public NotInheritable Class RouteCollectionExtensions
Private Sub New()
End Sub
<System.Runtime.CompilerServices.Extension()> _
Public Shared Sub MapRouteLowercase(ByVal routes As RouteCollection, ByVal name As String, ByVal url As String, ByVal defaults As Object)
routes.MapRouteLowercase(name, url, defaults, Nothing)
End Sub
<System.Runtime.CompilerServices.Extension()> _
Public Shared Sub MapRouteLowercase(ByVal routes As RouteCollection, ByVal name As String, ByVal url As String, ByVal defaults As Object, ByVal constraints As Object)
If routes Is Nothing Then
Throw New ArgumentNullException("routes")
End If
If url Is Nothing Then
Throw New ArgumentNullException("url")
End If
Dim route = New LowercaseRoute(url, New MvcRouteHandler()) With { _
.Defaults = New RouteValueDictionary(defaults), _
.Constraints = New RouteValueDictionary(constraints) _
}
If [String].IsNullOrEmpty(name) Then
routes.Add(route)
Else
routes.Add(name, route)
End If
End Sub
End Class
End Namespace