예제 #1
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);
        }
예제 #2
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));
        }
 public PropertyValueProviderState(ProjectConfiguration projectConfiguration, ProjectSystem.Properties.IProperty property)
 {
     ProjectConfiguration = projectConfiguration;
     Property             = property;
 }
예제 #4
0
        public static async Task <IEnumerable <IEntityValue> > CreateSupportedValuesAsync(IEntityValue parent, ProjectSystem.Properties.IProperty property, ISupportedValuePropertiesAvailableStatus requestedProperties)
        {
            if (property is ProjectSystem.Properties.IEnumProperty enumProperty)
            {
                ReadOnlyCollection <ProjectSystem.Properties.IEnumValue> enumValues = await enumProperty.GetAdmissibleValuesAsync();

                return(createSupportedValues(enumValues));
            }

            return(Enumerable.Empty <IEntityValue>());

            IEnumerable <IEntityValue> createSupportedValues(ReadOnlyCollection <ProjectSystem.Properties.IEnumValue> enumValues)
            {
                foreach (ProjectSystem.Properties.IEnumValue value in enumValues)
                {
                    IEntityValue supportedValue = CreateSupportedValue(parent.EntityRuntime, value, requestedProperties);
                    yield return(supportedValue);
                }
            }
        }
예제 #5
0
        public static IEnumerable <IEntityValue> CreateProjectConfigurationDimensions(IEntityValue parent, ProjectConfiguration configuration, ProjectSystem.Properties.IProperty property, IConfigurationDimensionPropertiesAvailableStatus requestedProperties)
        {
            // If the property is configuration-independent then report no dimensions;
            // the parent property value applies to all configurations.
            if (!property.DataSource.HasConfigurationCondition)
            {
                yield break;
            }

            foreach (KeyValuePair <string, string> dimension in configuration.Dimensions)
            {
                IEntityValue projectConfigurationDimension = CreateProjectConfigurationDimension(parent.EntityRuntime, dimension, requestedProperties);
                yield return(projectConfigurationDimension);
            }
        }