小编tre*_*ams的帖子

在 Powershell 中使用分隔符分割文件

我目前有一个 Powershell 脚本,它正在迭代捆绑的 MT103 文件。目前,它检查标志并决定是否转发文件。问题是,有时,MT177(不需要的)信息与所需的文件捆绑在一起,并且文件被转发到放置点。

如何修改我的 Powershell 脚本以根据分隔符“{-”检测并分割此文件。

例如:多次付款由换行符分隔。例如:

{-
MT103 payment 1
-}
{-
MT103 payment 2
-}
Run Code Online (Sandbox Code Playgroud)

我们的愿望是将这个文件分割成多个文件,然后单独处理它们。

生成的文件应包含

{-
MT103 payment 1
-}
Run Code Online (Sandbox Code Playgroud)
{-
MT103 payment 2
-}
Run Code Online (Sandbox Code Playgroud)

powershell split text-parsing

3
推荐指数
1
解决办法
3225
查看次数

Blazor 自定义身份验证提供程序错误

我正在创建一个 Blazor UI 应用程序来与 API 对话。目前,我正在尝试为此工作获取自定义提供程序,但出现了一些错误。

这是客户 AuthenticationStateProvider

public class APIAuthenticationStateProvider : AuthenticationStateProvider
{
    private readonly HttpClient _httpClient;
    private readonly ILocalStorageService _localStorage;
    public APIAuthenticationStateProvider(HttpClient httpClient, ILocalStorageService localStorage)
    {
        _httpClient = httpClient;
        _localStorage = localStorage;
    }
    public override async Task<AuthenticationState> GetAuthenticationStateAsync()
    {
        var token = await _localStorage.GetItemAsync<string>("authToken");

        if (string.IsNullOrWhiteSpace(token))
        {
            return new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity()));
        }

        _httpClient.DefaultRequestHeaders.Authorization =
            new AuthenticationHeaderValue("bearer", token);

        var claims = ParseClaims(token);

        return new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(claims,"jwt")));
    }
}
Run Code Online (Sandbox Code Playgroud)

我在 Startup.cs 文件中的配置服务功能如下所示

public void ConfigureServices(IServiceCollection services)
{
    services.AddRazorPages(); …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core blazor blazor-server-side blazor-client-side

1
推荐指数
2
解决办法
1212
查看次数