尝试将此代码从 C# 移植到 VB.NET(派生自 IHttpExecuteInterceptor)

Trying to port this code from C# to VB.NET (derives from IHttpExecuteInterceptor)

有一个答案 here 在 C# 中有这段代码:

public class GoogleBatchInterceptor : IHttpExecuteInterceptor
{
    public async Task InterceptAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        await Task.CompletedTask;
        if (request.Content is not MultipartContent multipartContent)
        {
            return;
        }
        
        foreach (var content in multipartContent)
        {
            content.Headers.Add("Content-ID", Guid.NewGuid().ToString());
        }
    }
}

我正在尝试将其移植到 VB.Net 并且我尝试从以下内容开始:

Imports Google.Apis.Http.IHttpExecuteInterceptor

Public Class GoogleBatchInterceptor :   IHttpExecuteInterceptor

End Class

它说:

Declaration expected.

如何移植此代码?这样我就可以暂时绕过 Google 日历 API issue


更新

我已经走到这一步了:

Imports System.Net.Http
Imports System.Threading
Imports Google.Apis.Http

Public Class GoogleBatchInterceptor
    Implements IHttpExecuteInterceptor

    Private Async Function IHttpExecuteInterceptor_InterceptAsync(request As HttpRequestMessage, cancellationToken As CancellationToken) As Task Implements IHttpExecuteInterceptor.InterceptAsync
        Await Task.CompletedTask
        'If request.Content Is Not MultipartContent multiplepartContent Then
        '    Return
        'End If

        'For Each (dim content)


    End Function
End Class

该 C# 代码中使用的模式匹配没有直接等效项。最接近的 VB 等价物是这样的:

Imports System.Net.Http
Imports System.Threading
Imports Google.Apis.Http

Public Class GoogleBatchInterceptor
    Implements IHttpExecuteInterceptor

    Public Async Function InterceptAsync(request As HttpRequestMessage, cancellationToken As CancellationToken) As Task Implements IHttpExecuteInterceptor.InterceptAsync
        Await Task.CompletedTask

        Dim multipartContent = TryCast(request.Content, MultipartContent)

        If multipartContent Is Nothing Then
            Return
        End If

        For Each content In multipartContent
            content.Headers.Add("Content-ID", Guid.NewGuid().ToString())
        Next
    End Function

End Class