Example #1
0
        public static async Task <IEnumerable <IEntityValue> > CreateUIPropertyValueValuesAsync(
            IEntityValue parent,
            IPropertyPageQueryCache cache,
            Rule schema,
            string propertyName,
            IUIPropertyValuePropertiesAvailableStatus requestedProperties)
        {
            ImmutableList <IEntityValue> .Builder builder = ImmutableList.CreateBuilder <IEntityValue>();

            if (await cache.GetKnownConfigurationsAsync() is IImmutableSet <ProjectConfiguration> knownConfigurations)
            {
                foreach (ProjectConfiguration knownConfiguration in knownConfigurations)
                {
                    if (await cache.BindToRule(knownConfiguration, schema.Name) is IRule rule &&
                        rule.GetProperty(propertyName) is ProjectSystem.Properties.IProperty property)
                    {
                        IEntityValue propertyValue = await CreateUIPropertyValueValueAsync(parent, knownConfiguration, property, requestedProperties);

                        builder.Add(propertyValue);
                    }
                }
            }

            return(builder.ToImmutable());
        }
Example #2
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());
Example #3
0
        public static async Task <IEntityValue> CreateUIPropertyValueValueAsync(IEntityRuntimeModel runtimeModel, EntityIdentity id, ProjectConfiguration configuration, ProjectSystem.Properties.IProperty property, IUIPropertyValuePropertiesAvailableStatus requestedProperties)
        {
            Requires.NotNull(property, nameof(property));

            var newUIPropertyValue = new UIPropertyValueValue(runtimeModel, id, new UIPropertyValuePropertiesAvailableStatus());

            if (requestedProperties.UnevaluatedValue)
            {
                if (property is IEvaluatedProperty evaluatedProperty)
                {
                    newUIPropertyValue.UnevaluatedValue = await evaluatedProperty.GetUnevaluatedValueAsync();
                }
                else
                {
                    newUIPropertyValue.UnevaluatedValue = await property.GetValueAsync() as string;
                }
            }

            if (requestedProperties.EvaluatedValue)
            {
                newUIPropertyValue.EvaluatedValue = property switch
                {
                    IBoolProperty boolProperty => await boolProperty.GetValueAsBoolAsync(),
                    IStringProperty stringProperty => await stringProperty.GetValueAsStringAsync(),
                    IIntProperty intProperty => await intProperty.GetValueAsIntAsync(),
                    IEnumProperty enumProperty => (await enumProperty.GetValueAsIEnumValueAsync())?.Name,
                    IStringListProperty stringListProperty => await stringListProperty.GetValueAsStringCollectionAsync(),
                    _ => await property.GetValueAsync()
                };
            }

            ((IEntityValueFromProvider)newUIPropertyValue).ProviderState = new PropertyValueProviderState(configuration, property);

            return(newUIPropertyValue);
        }
Example #4
0
        public static async Task <IEntityValue> CreateUIPropertyValueValueAsync(IEntityValue parent, ProjectConfiguration configuration, ProjectSystem.Properties.IProperty property, IUIPropertyValuePropertiesAvailableStatus requestedProperties)
        {
            Requires.NotNull(parent, nameof(parent));
            Requires.NotNull(configuration, nameof(configuration));
            Requires.NotNull(property, nameof(property));

            var identity = new EntityIdentity(
                ((IEntityWithId)parent).Id,
                Enumerable.Empty <KeyValuePair <string, string> >());

            return(await CreateUIPropertyValueValueAsync(parent.EntityRuntime, identity, configuration, property, requestedProperties));
        }
Example #5
0
 public UIPropertyValueFromUIPropertyDataProducer(IUIPropertyValuePropertiesAvailableStatus properties)
 {
     _properties = properties;
 }