Reputation: 36
After using converters (Redgate, Telerik, ...) I can not turn this expression c # to vb.net
if (afterItemRemoved != null)
{
cacheItemPolicy.RemovedCallback = x => afterItemRemoved(
x.CacheItem.Key,
(T)x.CacheItem.Value);
}
I have tried without success the following expressions (Reflector 8.5 de RedGate y converter.telerik.com)
If (afterItemRemoved IsNot Nothing) Then
cacheItemPolicy.RemovedCallback = x => afterItemRemoved.Invoke(x.CacheItem.Key, DirectCast(x.CacheItem.Value, T))
End If
If afterItemRemoved IsNot Nothing Then
cacheItemPolicy.RemovedCallback = Function(x) afterItemRemoved(x.CacheItem.Key, DirectCast(x.CacheItem.Value, T))
End If
Upvotes: 1
Views: 139
Reputation: 5049
Looking at the documentation for RemovedCallback we can see that the required delegate signature is a void
method (A Sub
in VB.Net) (see CacheEntryRemovedCallback).
So the lambda expression needed has to be a "Sub Lambda" not a "Function lambda"
If afterItemRemoved IsNot Nothing Then
cacheItemPolicy.RemoveCallback =
Sub(x) afterItemRemoved(x.CacheItem.Key, DirectCast(x.CacheItem.Value, T))
End If
Upvotes: 3