Exemplo n.º 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());
        }
Exemplo n.º 2
0
        public static async Task <IEnumerable <IEntityValue> > CreateUIPropertyValueValuesAsync(
            IEntityValue parent,
            IPropertyPageQueryCache cache,
            Rule schema,
            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.BindToRule(configuration, schema.Name) 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());