How to port C# code which uses a callback to VB.NET?

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2010-03-25T07:40:30Z Indexed on 2010/03/25 7:43 UTC
Read the original article Hit count: 169

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about vb.net