public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request) { Requires.NotNull(request, nameof(request)); if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (IPropertyPageQueryCache _, Rule schema, string propertyName)) { try { foreach (IEntityValue propertyEditor in UIPropertyEditorDataProducer.CreateEditorValues(request.RequestData, schema, propertyName, _properties)) { await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(propertyEditor, request, ProjectModelZones.Cps)); } } catch (Exception ex) { request.QueryExecutionContext.ReportError(ex); } } await ResultReceiver.OnRequestProcessFinishedAsync(request); }
public void WhenCreatingEditorsFromAProperty_OneEntityIsReturnedPerEditor() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyEditorPropertiesAvailableStatus(includeName: true); var context = IQueryExecutionContextFactory.Create(); var parentEntity = IEntityWithIdFactory.Create(key: "parentKey", value: "parentId"); var rule = new Rule(); rule.BeginInit(); rule.Properties.Add( new TestProperty { Name = "MyProperty", ValueEditors = { new ValueEditor { EditorType = "Alpha" }, new ValueEditor { EditorType = "Beta" }, new ValueEditor { EditorType = "Gamma" } } }); rule.EndInit(); var results = UIPropertyEditorDataProducer.CreateEditorValues(context, parentEntity, rule, "MyProperty", properties); Assert.Collection(results, new Action <IEntityValue>[] { entity => assertEqual(entity, expectedName: "Alpha"), entity => assertEqual(entity, expectedName: "Beta"), entity => assertEqual(entity, expectedName: "Gamma") });
protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IEntityValue parent, PropertyProviderState providerState) { return(Task.FromResult(UIPropertyEditorDataProducer.CreateEditorValues(parent, providerState.ContainingRule, providerState.PropertyName, _properties))); }