在代码示例(catcoding)中,支持 webview 逻辑被编写为 JavaScript 中的匿名函数,但我想在 Typescript 中构建此支持逻辑。
\n\n我厌倦了用 requireJS 将这个逻辑重现为打字稿包,但我无法让它工作。
\n\n// This script will be run within the webview itself\n// It cannot access the main VS Code APIs directly.\n(function () {\n const vscode = acquireVsCodeApi();\n\n\xe2\x80\xa6\n\n}();\nRun Code Online (Sandbox Code Playgroud)\n\n我希望在 TypeScript 中构建这个支持 WebView 逻辑,以便获得静态类型检查。
\n我在 VS Code 中有一个专门的 WebView 扩展,用于生成 .Net 类。这些文件是通过外部命令行工具生成的。命令行工具提供的功能之一是它以 JSON 格式写入特定文件,即生成的文件的位置。我在这个特定文件上设置了一个文件观察器,以便每当它更新时,我都会运行一个扩展方法来解析该 json 文件,从 json 中提取文件路径,然后在 VS Code 中打开该文件。
虽然这有效,但我的目的是在拆分编辑器中打开此文件,这样一侧显示我的 WebView (html),另一侧显示刚刚打开的文件(又名,谁的路径来自JSON 文件如上所述)。
如何在分割窗口的另一侧打开文件,同时保持我的 webview ext. 一侧视图和另一侧显示新打开的文件?
我的工作是这样的:它可以打开文件,但不能在分割视图编辑器中打开
// uri points to the file to read JSON from
let fileUri: vscode.Uri = vscode.Uri.file(uri.fsPath);
// read JSON from relative path of this file
fss.readFile(fileUri.fsPath, 'utf8', function (err, data)
{
if(!err) {
try{
// parse the data read from file as JSON
var jsonObj = JSON.parse(data);
try{
// create uri from path within json …Run Code Online (Sandbox Code Playgroud)我有一个 VS 2019 解决方案,其中包含三个已签入 Git 存储库的 .Net Core 3.x Web Api 项目。
我通过针对我的 Azure AKS 集群的向导在 Azure DevOps 中创建了一个构建管道。
创建了以下管道 YAML 文件。
运行此管道时,当它尝试复制 Web API 项目文件(如下面的日志中所述)时,我收到以下异常。
Step 6/38 : COPY ["BoundedContexts/BC1/API/NextWare.AppBuilder.BC1.API.csproj", "BoundedContexts/BC1/API/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder568816228/BoundedContexts/BC1/API/NextWare.AppBuilder.BC1.API.csproj: no such file or directory
Run Code Online (Sandbox Code Playgroud)
该文件位于存储库中,可通过 Azure DevOps 中的存储库查看器查看
这是 Azure DevOps 管道中失败的 docker 文件...
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["BoundedContexts/BC1/API/NextWare.AppBuilder.BC1.API.csproj", "BoundedContexts/BC1/API/"]
COPY ["Infrastructure/NextWare.Infrastructure.EventStore/NextWare.Infrastructure.EventStore.csproj", "Infrastructure/NextWare.Infrastructure.EventStore/"]
COPY ["Infrastructure/NextWare.Infrastructure/NextWare.Infrastructure.csproj", "Infrastructure/NextWare.Infrastructure/"]
COPY ["Infrastructure/NextWare.Infrastructure.EventBus/NextWare.Infrastructure.EventBus.csproj", "Infrastructure/NextWare.Infrastructure.EventBus/"]
COPY ["Infrastructure/NextWare.Infrastructure.EventBus.RabbitMQ/NextWare.Infrastructure.EventBus.RabbitMQ.csproj", "Infrastructure/NextWare.Infrastructure.EventBus.RabbitMQ/"] …Run Code Online (Sandbox Code Playgroud) continuous-integration azure-devops azure-pipelines azure-aks
我创建了一个 Azure 容器注册表(区域为 CentralCanada),然后从 Visual Studio 上传了 .Net 6.0 Web API 项目的 docker 映像。
成功部署 Linux 映像后,我可以在 Azure 容器中看到它。
然后,我尝试创建一个容器应用程序(环境也设置为 CentralCanada),在分配映像时,我选择 Azure 容器注册表,它按正确的名称显示我的容器注册表,但它说未找到映像。
为什么我看不到 Azure 容器注册表中的映像。
我可以使用默认的 HelloWorld 应用程序创建容器应用程序。
我在基于 ReactiveUI 的 ViewModel 中收到以下异常...
System.NotSupportedException:“常量”类型的表达式不受支持。您是否错过了表达式中的成员访问前缀?
该错误发生在ValidationEditorDocumentViewModel的构造函数内,位于可观察管道内,该管道旨在监视另一个响应式 ViewModel ( ValidationEditorViewModel ) 内的属性 ( SelectedValidatorClientViewModel ) 的更改。
我想做的是,每当 ValidationEditorViewModel.SelectedValidatorClientViewModel 属性发生更改时,然后在另一个 ViewModel (RuleEditorViewModel )上设置SelectedValidator。
using NextWare.ProductPortalUI.RXViewModels.RXViewModels.ValidationEditor;
using ReactiveUI;
using System;
namespace NextWare.ProductPortalUI.RXViewModels.ValidationEditor
{
public sealed partial class ValidationEditorDocumentViewModel: ReactiveObject
{
private ValidatorEditorViewModel _validationEditorViewModel;
private RuleEditorViewModel _ruleEditorViewModel;
public ValidationEditorDocumentViewModel()
{
var setValidatorRuleSet = this.WhenAnyValue(x => ValidationEditorViewModel.SelectedValidatorClientViewModel)
.Subscribe(_ => SetValidatorOnRuleSet());
}
private void SetValidatorOnRuleSet()
{
if(RuleEditorViewModel != null)
{
RuleEditorViewModel.SelectedValidator = _validationEditorViewModel.SelectedValidatorClientViewModel.Validator;
}
}
public ValidatorEditorViewModel ValidationEditorViewModel
{
get => …Run Code Online (Sandbox Code Playgroud) 我有以下班级关系
public interface ICapability
{
}
public interface IBaseService<T> where T : ICapability
{
}
public abstract class BaseService<out T> : IBaseService<T> where T : ICapability
{
// modified...
T MapEventToCapability(dynamic eventData, T capability);
}
public class SomeCapability : ICapability
{
}
public partial class Service1 : BaseService<SomeCapability>
{
public Service1()
{
}
}
public class ServiceResolver
{
public void Register(BaseService<ICapability> serviceToRegister)
{
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试调用 Register 方法,传入一个新的 service1,如下所示:
var b = new ServiceResolver();
var c = new Service1();
b.Register(c); …Run Code Online (Sandbox Code Playgroud) 我有两个 Web API 服务(源和目标)。每个都使用客户端密钥在 Azure B2C 中注册为 AD 应用程序。
我正在尝试调用从源服务到目标服务 API 的 gRPC API 调用,但是当我尝试进行调用时,出现 gRPC 异常,表明源未经身份验证。
注意:当我从目标 WebAPI 中删除范围策略和授权属性时,一切正常,但当然这是不安全的。
在源服务启动中我有以下内容......
注意:源和目标的配置设置都是正确的。我已经三次检查所有配置设置是否正确。
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddMicrosoftIdentityWebApi(options =>
{
Configuration.Bind("AzureAdB2C", options);
options.TokenValidationParameters.NameClaimType = "name";
},
options =>
{
Configuration.Bind("AzureAdB2C", options);
});
Run Code Online (Sandbox Code Playgroud)
我不确定是否需要,但我还在源 API 的启动中包含了以下逻辑。
注意:我现在已经对所需的范围进行了硬编码。
services.AddMicrosoftIdentityWebAppAuthentication(Configuration, "AzureAdB2C")
.EnableTokenAcquisitionToCallDownstreamApi(new string[] { "https://nextwaredev.onmicrosoft.com/nextware.productportal.sharedservices.api/sharedservices_readaccess", "https://nextwaredev.onmicrosoft.com/nextware.productportal.sharedservices.api/sharedservices_readwriteaccess" })
.AddInMemoryTokenCaches();
Run Code Online (Sandbox Code Playgroud)
目标服务具有正确的策略,并且两个服务都配置为使用授权和身份验证。
app.UseAuthentication();
app.UseAuthorization();
Run Code Online (Sandbox Code Playgroud)
我已经根据上面的相同范围添加了源所需的 API 权限。
当我尝试调用目标 API 上的方法时,我收到一个 gRPC 异常,表明源未经身份验证。
因此,我想也许我需要传递应用程序访问令牌,但是当我尝试获取 JWT 访问令牌时(以下示例 调用 tokenAcquisition.GetAccessTokenForAppAsync),我收到另一个异常“AADB2C90086:不支持提供的 grant_type [client_credentials]。 ”
注意:我有一个 Blazor 应用程序,调用相同的安全 API 时没有任何问题。不过,我调用 GetAccessTokenForUserAsync... ,它返回正确的令牌,并具有调用相同下游源或目标 Web api 服务所需的应用范围。 …
c# ×3
.net ×1
azure ×1
azure-ad-b2c ×1
azure-aks ×1
azure-devops ×1
class ×1
inheritance ×1
reactiveui ×1
typescript ×1