我有一个角度材质选择组件,我想将下拉列表的选定值绑定到来自firebase的Observable of scalar.我想这样做而不需要解开组件中的observable.它看起来我无法使用异步管道绑定值.下面的代码抛出一个异常,因为mat-select的值不能绑定到"uiStateSvc.currentClient $ | async".
<mat-form-field *ngIf="(store.authorizedClients$ | async)?.length > 0">
<mat-select [(value)]="uiStateSvc.currentClient$ | async" [compareWith]="compareFn">
<mat-option *ngFor="let client of store.authorizedClients$ | async" [value]="client"
(onSelectionChange)="changeCurrentClient($event, client)">
{{ client.name}}
</mat-option>
</mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
我从firebase中提取下拉列表的当前选定值,如下所示:
this.selectedClient$ = this.authSvc.currentUser$.pipe(
switchMap((x: firebase.User) => {
if (x != null) {
return this.afs.doc(`uistate/${x.uid}`).valueChanges().map((y: any) => y.selectedclient);
} else {
return Observable.of(null);
}
})
);
Run Code Online (Sandbox Code Playgroud) 我创建了一个 Asp.Net Core 托管的 Blazor webassembly 3.2.0 Preview 3 应用程序,其中包含应用程序内帐户的身份验证选项。然后我向 ApplicationUser 类添加了一些额外的属性,并将这些更改迁移到数据库。然后我实现了一个自定义声明工厂,如下所示:
public class MyCustomUserClaimsPrincipalFactory : UserClaimsPrincipalFactory<ApplicationUser>
{
public MyCustomUserClaimsPrincipalFactory(
UserManager<ApplicationUser> userManager,
IOptions<IdentityOptions> optionsAccessor)
: base(userManager, optionsAccessor)
{
}
protected override async Task<ClaimsIdentity> GenerateClaimsAsync(ApplicationUser user)
{
var identity = await base.GenerateClaimsAsync(user);
identity.AddClaim(new Claim(ClaimTypes.GivenName, user.FirstName ?? string.Empty));
.....
return identity;
}
}
Run Code Online (Sandbox Code Playgroud)
并在服务器应用程序中注册声明工厂,如下所示:
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddClaimsPrincipalFactory<MyCustomUserClaimsPrincipalFactory>();
Run Code Online (Sandbox Code Playgroud)
但是,当我在客户端 Web 应用程序组件中列出声明时,我没有看到我在自定义声明工厂中添加的任何其他声明。我用来列出索赔的代码是:
<AuthorizeView>
<Authorized>
<ul>
@foreach (var claim in context.User.Claims)
{
<li><span>@claim.Type</span><span>@claim.Value</span></li>
}
</ul>
</Authorized>
</AuthorizeView>
Run Code Online (Sandbox Code Playgroud)
我确认正在调用声明工厂代码。如何在客户端 Web 应用程序中获取其他声明?
编辑:我甚至用ClaimsTransformer(如建议尝试 …
我了解在IMDB审阅分类中只有一个文本功能的情况下如何使用Keras嵌入层。但是,当我遇到一个分类问题(其中有多个文本功能)时,我对如何使用嵌入层感到困惑。例如,我有一个具有2个文本特征“诊断文本”和“请求的过程”的数据集,并且标签是二进制类(1表示批准,0表示未批准)。在下面的示例中,与IMDB数据集不同,x_train具有2列“诊断”和“过程”。我是否需要创建2个嵌入层,其中一个用于诊断和过程?如果是这样,将需要更改哪些代码?
x_train = preprocessing.sequences.pad_sequences(x_train, maxlen=20)
x_test = preprocessing.sequences.pad_sequences(x_test, maxlen=20)
model = Sequential()
model.add(Embedding(10000,8,input_length=20)
model.add(Flatten())
model.add(Dense(1, activation='sigmoid')
model.compile(optimizer='rmsprop', loss='binary_crossentropy', metrics=['acc'])
model.fit(x_train, y_train, epochs=10, batch_size=32, validation_split=0.2)
Run Code Online (Sandbox Code Playgroud) 我正在通过使用FormFlow构建机器人来构建Coratana技能.我使用LUIS检测我的意图和实体,并将实体传递给我的FormFlow对话框.如果未填写一个或多个FormFlow字段,FormFlow对话框将提示用户填写缺少的信息,但不会说出此提示,仅显示在cortana屏幕上.FormFlow有没有办法说出提示?
在下面显示的屏幕截图中,提示"你需要机场班车吗?" 刚刚显示而没有说出来:
我的formFlow定义如下所示:
[Serializable]
public class HotelsQuery
{
[Prompt("Please enter your {&}")]
[Optional]
public string Destination { get; set; }
[Prompt("Near which Airport")]
[Optional]
public string AirportCode { get; set; }
[Prompt("Do you need airport shuttle?")]
public string DoYouNeedAirportShutle { get; set; }
}
Run Code Online (Sandbox Code Playgroud) 下面的代码示例来自ConfigureServices
Startup.cs 中的Asp.Net Core方法。
我首先注册一个名为AppState
. 之后,我正在配置 OpenIdConnect,并且在OnTokenValidated
lambda内部,我需要访问AppState
我刚刚在上面的 DI 容器中注册的服务。
访问AppState
服务实例的最优雅的方式是什么?
如果可能的话,我宁愿不在方法services.BuildServiceProvider()
内部调用ConfigureServices
。
services.AddSingleton<AppState>();
services.Configure<OpenIdConnectOptions>(AzureADB2CDefaults.OpenIdScheme, options =>
{
options.Events = new OpenIdConnectEvents
{
OnTokenValidated = async ctx =>
{
//How to get access to instance of AppState,
//which was added to DI container up above
AppState appState = //{get from DI somehow};
appState.DoSomething();
}
};
});
Run Code Online (Sandbox Code Playgroud)
编辑:使用下面的答案,我像这样编辑了代码,但我可以确认 OnTokenValidated 事件没有触发,而不是我原始问题中的上面的代码,它确实触发了:
services.AddOptions<OpenIdConnectOptions>(AzureADB2CDefaults.OpenIdScheme)
.Configure<IServiceScopeFactory>((options, sp) => {
using (var scope = sp.CreateScope()) …
Run Code Online (Sandbox Code Playgroud) c# ×2
angular ×1
angularfire2 ×1
asp.net-core ×1
botframework ×1
firebase ×1
formflow ×1
keras ×1
observable ×1
rxjs6 ×1
word2vec ×1