我正在使用Service Bus 2.1对于Windows Server,我有一种方法来异步接收消息.
我方法的主体是:
var waitTimeout = TimeSpan.FromSeconds(10);
// Declare an action acting as a callback whenever a message arrives on a queue.
AsyncCallback completeReceive = null;
// Declare an action acting as a callback whenever a non-transient exception occurs while receiving or processing messages.
Action<Exception> recoverReceive = null;
// Declare an action responsible for the core operations in the message receive loop.
Action receiveMessage = () =>
{
// Use a retry policy to execute the Receive action …
Run Code Online (Sandbox Code Playgroud) 我正在将Angular 1.6代码转换为Angular 4,我遇到了一个元素列表问题.Angular 1.6中的代码是:
<select ng-model="$ctrl.level" ng-options="item as item.label for item in $ctrl.referentiel.levels | orderBy : 'index' track by item.id" id="childLevel" name="childLevel" class="size-xl" >
<option value="">Select</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我的列表中未引用对象级别,因为使用对象referentiel.levels加载此列表.但是由于trackby,我的列表元素和我的对象级别之间的匹配完成.因此,当加载我的对象级别时,将在列表中选择该元素.
现在,我尝试使用Reactive Forms转换此代码.在我的HTML代码中,我有:
<select formControlName="levelControl" id="levelSelect" name="levelSelect" class="size-xl">
<option [ngValue]="null">Select</option>
<option *ngFor="let level of referentiel.levels;trackBy:identify" [ngValue]="level">{{level.label }}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
在我的组件中,我有OnInit方法:
(<FormControl>this.myForm.controls.levelControl).setValue(this.level);
Run Code Online (Sandbox Code Playgroud)
方法识别很简单:
identify(index,item){
return item.id;
}
Run Code Online (Sandbox Code Playgroud)
但是这种竞争是不同的.当我使用对象Level设置我的控件的值时,未选择列表中具有相同id的项.
我找到了解决方案,但我不明白为什么它不起作用.我的解决方法是用HTML编写此代码:
<option *ngFor="let level of referentiel.levels;trackBy:identify" [ngValue]="level.id">{{level.label }}</option>
Run Code Online (Sandbox Code Playgroud)
在我的打字稿文件中:
(<FormControl>this.myForm.controls.levelControl).setValue(this.level.id);
Run Code Online (Sandbox Code Playgroud)
所以,现在它正在工作:我的项目在列表中被选中.
在这种情况下,我不明白两个版本的Angular之间的区别.也许我错过了什么......
谢谢你的帮助.
我有一个延迟加载的组件和一个参数的问题。我有两个模块:一个仪表板模块 (DashboardModule) 带有一个仪表板组件 (DashboardComponent),另一个名为 user (UserModule) 的模块带有一个组件 (UserComponent),例如。UserComponent 用于显示一个用户或创建一个新用户。我想延迟加载模块 UserModule。所以我在文件 app.routing.ts 中的配置是:
export const appRoutes: Routes = [
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: '**', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: 'user', loadChildren: 'app/user/user.module#UserModule' },
]
@NgModule({
imports: [ RouterModule.forRoot(appRoutes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}
Run Code Online (Sandbox Code Playgroud)
现在,在我的模块 User 中,我有一个文件来配置我的路由:user.routing.ts。我想为我的两种情况使用相同的路线:如果我的路线中有一个 id,则显示一个用户,或者如果 id 为空,则创建一个用户。所以我尝试这个,但它不起作用:
const userRoutes: Routes = [
{ path: '', component: UserComponent },
{ path: ':id', component: UserComponent } // This …
Run Code Online (Sandbox Code Playgroud) 我有一个图形方法CancelChanges()使用和ViewModel调用.我想测试这个方法,但我们内部有一个Task.我们使用Task来不冻结UI.我的测试方法需要等待此任务的结果来检查结果.
代码是:
public override void CancelChanges()
{
Task.Run(
async () =>
{
this.SelectedWorkflow = null;
AsyncResult<IncidentTypeModel> asyncResult = await this.Dataprovider.GetIncidentTypeByIdAsync(this.Incident.Id);
Utils.GetDispatcher().Invoke(
() =>
{
if (asyncResult.IsError)
{
WorkflowMessageBox.ShowException(
MessageHelper.ManageException(asyncResult.Exception));
}
else
{
this.Incident = asyncResult.Result;
this.Refreshdesigner();
this.HaveChanges = false;
}
});
});
}
Run Code Online (Sandbox Code Playgroud)
而我的测试方法:
/// <summary>
/// A test for CancelChanges
/// </summary>
[TestMethod]
[TestCategory("ConfigTool")]
public void CancelChangesTest()
{
string storexaml = this._target.Incident.WorkflowXamlString;
this._target.Incident.WorkflowXamlString = "dsdfsdgfdsgdfgfd";
this._target.CancelChanges();
Assert.IsTrue(storexaml == this._target.Incident.WorkflowXamlString);
Assert.IsFalse(this._target.HaveChanges);
}
Run Code Online (Sandbox Code Playgroud)
我们如何让我的测试等待任务的结果?
谢谢.