我正在开发一个基于 Docker 和微服务的新 ASP.NET Core Web 项目,我想知道是否有一种方法可以避免在appsettings.json.
我的问题是如何在项目外部指定机密,以便它们不会意外提交到源代码存储库(使用 Azure Key Vault 或其他东西)。
我的期望是结合两个配置提供程序,例如一些外部密钥存储(如果没有其他解决方案或处理此类目的的方法)和应用程序配置。
我在尝试渲染 ClientDetails 组件并在 props 中传递 Client 列表时遇到编译问题:
我收到此错误消息:
Type '{ (): Promise<JSX.Element>; propTypes: {}; }' is not assignable to type 'ComponentClass<any, any> | FunctionComponent<any> | ComponentClass<RouteComponentProps<any, StaticContext, {}>, any> | FunctionComponent<...>'.
Type '{ (): Promise<JSX.Element>; propTypes: {}; }' is not assignable to type 'FunctionComponent<any>'.
Type 'Promise<Element>' is missing the following properties from type 'ReactElement<any, any>': type, props, key
Run Code Online (Sandbox Code Playgroud)
我的 renderClientsTable 函数:
static async renderClientsTable(clients: Readonly<IClientModel[]>) {
return (
<table className='table table-striped' aria-labelledby="tabelLabel">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Url</th>
<th>Status</th>
</tr>
</thead> …Run Code Online (Sandbox Code Playgroud) 允许将通常的事件处理程序从 void 转换为基于任务并等待它,如下所示?
Something.PropertyChanged += async (o, args) => await IsButtonVisible_PropertyChanged(o, args);
Something.PropertyChanged -= async (o, args) => await IsButtonVisible_PropertyChanged(o, args);
private Task IsButtonVisible_PropertyChanged(object sender,PropertyChangedEventArgs e)
{
if (IsSomthingEnabled)
{
return SomeService.ExecuteAsync(...);
}
return Task.CompletedTask;
}
Run Code Online (Sandbox Code Playgroud)
或者像这样做?
Something.PropertyChanged += IsButtonVisible_PropertyChanged;
Something.PropertyChanged -= IsButtonVisible_PropertyChanged;
private void IsButtonVisible_PropertyChanged(object sender,PropertyChangedEventArgs e)
{
if (IsSomthingEnabled)
{
_ = SomeService.ExecuteAsync(...);
}
}
Run Code Online (Sandbox Code Playgroud)
更新: 或者这个,我知道 use Task void 应该被禁止,因为它没有捕获异常,但对于事件处理程序的情况可能没问题,因为事件处理程序不返回。
Something.PropertyChanged += IsButtonVisible_PropertyChanged;
Something.PropertyChanged -= IsButtonVisible_PropertyChanged;
private async void IsButtonVisible_PropertyChanged(object sender,PropertyChangedEventArgs e)
{
if (IsSomthingEnabled)
{
await …Run Code Online (Sandbox Code Playgroud) c# ×2
appsettings ×1
asp.net-core ×1
async-await ×1
asynchronous ×1
es6-promise ×1
eventhandler ×1
promise ×1
reactjs ×1
security ×1
typescript ×1