How to port C# code which uses a callback to VB.NET?
- by Bob
I need to port the following from the ASP.NET MVC 2 sourcecode from C# to VB.NET. It's from AuthorizeAttribute.cs beginning on line 86:
HttpCachePolicyBase cachePolicy = filterContext.HttpContext.Response.Cache;
cachePolicy.SetProxyMaxAge(new TimeSpan(0));
cachePolicy.AddValidationCallback(CacheValidateHandler, null /* data */);
where CacheValidateHandler is:
private void CacheValidateHandler(HttpContext context, object data,
ref HttpValidationStatus validationStatus) {
validationStatus = OnCacheAuthorization(new HttpContextWrapper(context));
}
The VB.NET port from http://converter.telerik.com doesn't quite work for this line:
cachePolicy.AddValidationCallback(CacheValidateHandler, Nothing) ' Error
where CacheValidateHandler is:
Private Sub CacheValidateHandler(ByVal context As HttpContext, ByVal data As Object, _
ByRef validationStatus As HttpValidationStatus)
validationStatus = OnCacheAuthorization(New HttpContextWrapper(context))
End Sub
VS2008 complains that CacheValidateHandler does not specify its arguments for context, data, and validationStatus.
Any ideas how to port this code?