Beispiel #1
0
        public static async Task <IEnumerable <IEntityValue> > CreateUIPropertyValueValuesAsync(
            IQueryExecutionContext queryExecutionContext,
            IEntityValue parent,
            IProjectState cache,
            Rule schema,
            QueryProjectPropertiesContext propertiesContext,
            string propertyName,
            IUIPropertyValuePropertiesAvailableStatus requestedProperties)
        {
            BaseProperty?unboundProperty = schema.GetProperty(propertyName);

            if (unboundProperty is null)
            {
                return(ImmutableList <IEntityValue> .Empty);
            }

            ImmutableList <IEntityValue> .Builder builder = ImmutableList.CreateBuilder <IEntityValue>();

            IEnumerable <ProjectConfiguration> configurations;

            if (unboundProperty.IsConfigurationDependent())
            {
                // Return the values across all configurations.
                configurations = await cache.GetKnownConfigurationsAsync() ?? Enumerable.Empty <ProjectConfiguration>();
            }
            else
            {
                // Return the value from any one configuration.
                if (await cache.GetSuggestedConfigurationAsync() is ProjectConfiguration defaultConfiguration)
                {
                    configurations = CreateSingleItemEnumerable(defaultConfiguration);
                }
                else
                {
                    configurations = Enumerable.Empty <ProjectConfiguration>();
                }
            }

            foreach (ProjectConfiguration configuration in configurations)
            {
                if (await cache.GetDataVersionAsync(configuration) is (string versionKey, long versionNumber))
                {
                    queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);
                }

                if (await cache.BindToRuleAsync(configuration, schema.Name, propertiesContext) is IRule rule &&
                    rule.GetProperty(propertyName) is ProjectSystem.Properties.IProperty property)
                {
                    IEntityValue propertyValue = await CreateUIPropertyValueValueAsync(parent, configuration, property, requestedProperties);

                    builder.Add(propertyValue);
                }
            }

            return(builder.ToImmutable());
        public async Task ReceiveResultAsync(QueryProcessResult <IEntityValue> result)
        {
            result.Request.QueryExecutionContext.CancellationToken.ThrowIfCancellationRequested();
            if (((IEntityValueFromProvider)result.Result).ProviderState is ContextAndRuleProviderState state)
            {
                IProjectState projectState = state.ProjectState;
                if (await projectState.GetSuggestedConfigurationAsync() is ProjectConfiguration configuration &&
                    await projectState.BindToRuleAsync(configuration, state.Rule.Name, state.PropertiesContext) is IRule boundRule &&
                    boundRule.GetProperty(_executableStep.PropertyName) is IProperty property)
                {
                    await property.SetValueAsync(_executableStep.Value);

                    if (await projectState.GetDataVersionAsync(configuration) is (string versionKey, long versionNumber))
                    {
                        result.Request.QueryExecutionContext.ReportUpdatedDataVersion(versionKey, versionNumber);
                    }
                }
            }

            await ResultReceiver.ReceiveResultAsync(result);
        }