public async Task SendRequestAsync(QueryProcessRequest <IReadOnlyCollection <EntityIdentity> > request) { Requires.NotNull(request, nameof(request)); foreach (EntityIdentity requestId in request.RequestData) { if (requestId.KeysCount == 2 && requestId.TryGetValue(ProjectModelIdentityKeys.ProjectPath, out string path) && requestId.TryGetValue(ProjectModelIdentityKeys.PropertyPageName, out string propertyPageName)) { try { IEntityValue?propertyPageValue = await PropertyPageDataProducer.CreatePropertyPageValueAsync( request.QueryExecutionContext.EntityRuntime, requestId, _projectService, _queryCacheProvider, path, propertyPageName, _properties); if (propertyPageValue is not null) { await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(propertyPageValue, request, ProjectModelZones.Cps)); } } catch (Exception ex) { request.QueryExecutionContext.ReportError(ex); } } } await ResultReceiver.OnRequestProcessFinishedAsync(request); }
protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, UnconfiguredProject providerState) { providerState.GetQueryDataVersion(out string versionKey, out long versionNumber); queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber); return(PropertyPageDataProducer.CreatePropertyPageValuesAsync(queryExecutionContext, parent, providerState, _properties)); }
public void WhenCreatingFromAParentAndRule_TheRuleNameIsTheEntityId() { var properties = PropertiesAvailableStatusFactory.CreatePropertyPagePropertiesAvailableStatus(); var propertyPage = (PropertyPageValue)PropertyPageDataProducer.CreatePropertyPageValue( IEntityWithIdFactory.Create(key: "ParentKey", value: "ParentValue"), IPropertyPageQueryCacheFactory.Create(), new Rule { Name = "MyRule", DisplayName = "My Rule Display Name", Order = 42, PageTemplate = "generic" }, properties); Assert.Equal(expected: "MyRule", actual: propertyPage.Id[ProjectModelIdentityKeys.PropertyPageName]); }
public void WhenCreatingAModel_ProviderStateConsistsOfCacheAndRule() { var properties = PropertiesAvailableStatusFactory.CreatePropertyPagePropertiesAvailableStatus(); var propertyPage = (IEntityValueFromProvider)PropertyPageDataProducer.CreatePropertyPageValue( IEntityRuntimeModelFactory.Create(), new EntityIdentity(key: "A", value: "B"), IPropertyPageQueryCacheFactory.Create(), new Rule { Name = "MyRule", DisplayName = "My Rule Display Name", Order = 42, PageTemplate = "generic" }, properties); Assert.IsType <(IPropertyPageQueryCache, Rule)>(propertyPage.ProviderState); }
public void WhenCreatingAModel_ProviderStateIsTheCorrectType() { var properties = PropertiesAvailableStatusFactory.CreatePropertyPagePropertiesAvailableStatus(includeAllProperties: true); var propertyPage = (IEntityValueFromProvider)PropertyPageDataProducer.CreatePropertyPageValue( IEntityWithIdFactory.Create(key: "A", value: "B"), IPropertyPageQueryCacheFactory.Create(), new Rule { Name = "MyRule", DisplayName = "My Rule Display Name", Order = 42, PageTemplate = "generic" }, debugChildRules: new List <Rule>(), properties); Assert.IsType <PropertyPageProviderState>(propertyPage.ProviderState); }
protected override Task <IEntityValue?> TryCreateEntityOrNullAsync(IQueryExecutionContext queryExecutionContext, EntityIdentity id) { if (QueryProjectPropertiesContext.TryCreateFromEntityId(id, out QueryProjectPropertiesContext? propertiesContext) && id.TryGetValue(ProjectModelIdentityKeys.PropertyPageName, out string?propertyPageName)) { return(PropertyPageDataProducer.CreatePropertyPageValueAsync( queryExecutionContext, id, _projectService, propertiesContext, propertyPageName, _properties)); } return(NullEntityValue); }
public void WhenCreatingFromAParentAndRule_TheRuleNameIsTheEntityId() { var properties = PropertiesAvailableStatusFactory.CreatePropertyPagePropertiesAvailableStatus(includeAllProperties: true); var propertyPage = (PropertyPageValue)PropertyPageDataProducer.CreatePropertyPageValue( IQueryExecutionContextFactory.Create(), IEntityWithIdFactory.Create(key: "ParentKey", value: "ParentValue"), IProjectStateFactory.Create(), QueryProjectPropertiesContext.ProjectFile, new Rule { Name = "MyRule", DisplayName = "My Rule Display Name", Order = 42, PageTemplate = "generic" }, requestedProperties: properties); Assert.Equal(expected: "MyRule", actual: propertyPage.Id[ProjectModelIdentityKeys.PropertyPageName]); }
public void WhenCreatingAModel_ProviderStateIsTheCorrectType() { var properties = PropertiesAvailableStatusFactory.CreatePropertyPagePropertiesAvailableStatus(includeAllProperties: true); var propertyPage = (IEntityValueFromProvider)PropertyPageDataProducer.CreatePropertyPageValue( IQueryExecutionContextFactory.Create(), IEntityWithIdFactory.Create(key: "A", value: "B"), IProjectStateFactory.Create(), QueryProjectPropertiesContext.ProjectFile, new Rule { Name = "MyRule", DisplayName = "My Rule Display Name", Order = 42, PageTemplate = "generic" }, requestedProperties: properties); Assert.IsType <ContextAndRuleProviderState>(propertyPage.ProviderState); }
public void WhenPropertyValuesAreRequested_PropertyValuesAreReturned() { var properties = PropertiesAvailableStatusFactory.CreatePropertyPagePropertiesAvailableStatus(); var propertyPage = (PropertyPageValue)PropertyPageDataProducer.CreatePropertyPageValue( IEntityRuntimeModelFactory.Create(), new EntityIdentity(key: "A", value: "B"), IPropertyPageQueryCacheFactory.Create(), new Rule { Name = "MyRule", DisplayName = "My Rule Display Name", Order = 42, PageTemplate = "generic" }, properties); Assert.Equal(expected: "MyRule", actual: propertyPage.Name); Assert.Equal(expected: "My Rule Display Name", actual: propertyPage.DisplayName); Assert.Equal(expected: 42, actual: propertyPage.Order); Assert.Equal(expected: "generic", actual: propertyPage.Kind); }
public void WhenPropertyValuesAreRequested_PropertyValuesAreReturned() { var properties = PropertiesAvailableStatusFactory.CreatePropertyPagePropertiesAvailableStatus(includeAllProperties: true); var propertyPage = (PropertyPageValue)PropertyPageDataProducer.CreatePropertyPageValue( IEntityWithIdFactory.Create(key: "A", value: "B"), IPropertyPageQueryCacheFactory.Create(), new Rule { Name = "MyRule", DisplayName = "My Rule Display Name", Order = 42, PageTemplate = "generic" }, debugChildRules: new List <Rule>(), properties); Assert.Equal(expected: "MyRule", actual: propertyPage.Name); Assert.Equal(expected: "My Rule Display Name", actual: propertyPage.DisplayName); Assert.Equal(expected: 42, actual: propertyPage.Order); Assert.Equal(expected: "generic", actual: propertyPage.Kind); }
protected override Task <IEntityValue?> TryCreateEntityOrNullAsync(IEntityRuntimeModel runtimeModel, EntityIdentity id) { if (id.KeysCount == 2 && id.TryGetValue(ProjectModelIdentityKeys.ProjectPath, out string projectPath) && id.TryGetValue(ProjectModelIdentityKeys.PropertyPageName, out string propertyPageName)) { return(PropertyPageDataProducer.CreatePropertyPageValueAsync( runtimeModel, id, _projectService, _queryCacheProvider, projectPath, propertyPageName, _properties)); } return(NullEntityValue); }
public void WhenPropertyValuesAreRequested_PropertyValuesAreReturned() { var properties = PropertiesAvailableStatusFactory.CreatePropertyPagePropertiesAvailableStatus(includeAllProperties: true); var propertyPage = (PropertyPageValue)PropertyPageDataProducer.CreatePropertyPageValue( IQueryExecutionContextFactory.Create(), IEntityWithIdFactory.Create(key: "A", value: "B"), IProjectStateFactory.Create(), QueryProjectPropertiesContext.ProjectFile, new Rule { Name = "MyRule", DisplayName = "My Rule Display Name", Order = 42, PageTemplate = "generic" }, requestedProperties: properties); Assert.Equal(expected: "MyRule", actual: propertyPage.Name); Assert.Equal(expected: "My Rule Display Name", actual: propertyPage.DisplayName); Assert.Equal(expected: 42, actual: propertyPage.Order); Assert.Equal(expected: "generic", actual: propertyPage.Kind); }
public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request) { Requires.NotNull(request, nameof(request)); if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is UnconfiguredProject project) { try { IEnumerable <IEntityValue> propertyPageValues = await PropertyPageDataProducer.CreatePropertyPageValuesAsync(request.RequestData, project, _properties); foreach (IEntityValue propertyPageValue in propertyPageValues) { await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(propertyPageValue, request, ProjectModelZones.Cps)); } } catch (Exception ex) { request.QueryExecutionContext.ReportError(ex); } } await ResultReceiver.OnRequestProcessFinishedAsync(request); }
protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IEntityValue parent, UnconfiguredProject providerState) { return(PropertyPageDataProducer.CreatePropertyPageValuesAsync(parent, providerState, _queryCacheProvider, _properties)); }
protected override Task <IEnumerable <IEntityValue> > CreateValuesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, UnconfiguredProject providerState) { queryExecutionContext.ReportProjectVersion(providerState); return(PropertyPageDataProducer.CreatePropertyPageValuesAsync(queryExecutionContext, parent, providerState, _projectStateProvider, _properties)); }