mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
23 lines
727 B
C#
23 lines
727 B
C#
using System.Web;
|
|
using System.Web.Routing;
|
|
using Orchard.Blogs.Models;
|
|
|
|
namespace Orchard.Blogs.Routing {
|
|
public class IsArchiveConstraint : IRouteConstraint {
|
|
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values,
|
|
RouteDirection routeDirection) {
|
|
if(values[parameterName] == null) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
var archiveData = new ArchiveData(values[parameterName].ToString());
|
|
archiveData.ToDateTime();
|
|
return true;
|
|
}
|
|
catch {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
} |