public void WhenAnEditorValueIsCreated_TheEditorIsTheProviderState() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyEditorPropertiesAvailableStatus(includeName: true); var context = IQueryExecutionContextFactory.Create(); var id = new EntityIdentity(key: "EditorKey", value: "bbb"); var editor = new ValueEditor { EditorType = "My.Editor.Type" }; var result = (UIPropertyEditorValue)UIPropertyEditorDataProducer.CreateEditorValue(context, id, editor, properties); Assert.Equal(expected: editor, actual: ((IEntityValueFromProvider)result).ProviderState); }
public void WhenPropertiesAreRequested_PropertyValuesAreReturned() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyEditorPropertiesAvailableStatus(includeName: true); var context = IQueryExecutionContextFactory.Create(); var id = new EntityIdentity(key: "EditorKey", value: "bbb"); var editor = new ValueEditor { EditorType = "My.Editor.Type" }; var result = (UIPropertyEditorValue)UIPropertyEditorDataProducer.CreateEditorValue(context, id, editor, properties); Assert.Equal(expected: "My.Editor.Type", actual: result.Name); }
public void WhenCreatingAnEntityFromAParentAndEditor_TheIdIsTheEditorType() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyEditorPropertiesAvailableStatus(includeName: false); var context = IQueryExecutionContextFactory.Create(); var parentEntity = IEntityWithIdFactory.Create(key: "parentId", value: "aaa"); var editor = new ValueEditor { EditorType = "My.Editor.Type" }; var result = (UIPropertyEditorValue)UIPropertyEditorDataProducer.CreateEditorValue(context, parentEntity, editor, properties); Assert.Equal(expected: "My.Editor.Type", actual: result.Id[ProjectModelIdentityKeys.EditorName]); }
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); }
protected override Task <IEntityValue?> TryCreateEntityOrNullAsync(IQueryExecutionContext queryExecutionContext, EntityIdentity id) { if (id.KeysCount == 4 && id.TryGetValue(ProjectModelIdentityKeys.ProjectPath, out string projectPath) && id.TryGetValue(ProjectModelIdentityKeys.PropertyPageName, out string propertyPageName) && id.TryGetValue(ProjectModelIdentityKeys.UIPropertyName, out string propertyName) && id.TryGetValue(ProjectModelIdentityKeys.EditorName, out string editorName)) { return(UIPropertyEditorDataProducer.CreateEditorValueAsync( queryExecutionContext, id, _projectService, projectPath, propertyPageName, propertyName, editorName, _properties)); } return(NullEntityValue); }
public async Task SendRequestAsync(QueryProcessRequest <IReadOnlyCollection <EntityIdentity> > request) { Requires.NotNull(request, nameof(request)); foreach (EntityIdentity requestId in request.RequestData) { if (requestId.KeysCount == 4 && requestId.TryGetValue(ProjectModelIdentityKeys.ProjectPath, out string path) && requestId.TryGetValue(ProjectModelIdentityKeys.PropertyPageName, out string propertyPageName) && requestId.TryGetValue(ProjectModelIdentityKeys.UIPropertyName, out string propertyName) && requestId.TryGetValue(ProjectModelIdentityKeys.EditorName, out string editorName)) { try { IEntityValue?propertyEditor = await UIPropertyEditorDataProducer.CreateEditorValueAsync( request.QueryExecutionContext.EntityRuntime, requestId, _projectService, path, propertyPageName, propertyName, editorName, _properties); if (propertyEditor is not null) { 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))); }