Ejemplo n.º 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);
        }
 public static IEnumerable <IEntityValue> CreateMetadataValues(IEntityRuntimeModel runtimeModel, ValueEditor editor, IUIEditorMetadataPropertiesAvailableStatus requestedProperties)
 {
     foreach (NameValuePair metadataPair in editor.Metadata)
     {
         IEntityValue metadataValue = CreateMetadataValue(runtimeModel, metadataPair, requestedProperties);
         yield return(metadataValue);
     }
 }
        public static IEntityValue CreateMetadataValue(IEntityRuntimeModel runtimeModel, NameValuePair metadata, IUIEditorMetadataPropertiesAvailableStatus requestedProperties)
        {
            var newMetadata = new UIEditorMetadataValue(runtimeModel, new UIEditorMetadataPropertiesAvailableStatus());

            if (requestedProperties.Name)
            {
                newMetadata.Name = metadata.Name;
            }

            if (requestedProperties.Value)
            {
                newMetadata.Value = metadata.Value;
            }

            return(newMetadata);
        }
Ejemplo n.º 4
0
        public static IEntityValue CreateSupportedValue(IEntityRuntimeModel runtimeModel, ProjectSystem.Properties.IEnumValue enumValue, ISupportedValuePropertiesAvailableStatus requestedProperties)
        {
            var newSupportedValue = new SupportedValueValue(runtimeModel, new SupportedValuePropertiesAvailableStatus());

            if (requestedProperties.DisplayName)
            {
                newSupportedValue.DisplayName = enumValue.DisplayName;
            }

            if (requestedProperties.Value)
            {
                newSupportedValue.Value = enumValue.Name;
            }

            return(newSupportedValue);
        }
Ejemplo n.º 5
0
        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 static IEntityValue CreateProjectConfigurationDimension(
            IEntityRuntimeModel runtimeModel,
            KeyValuePair <string, string> projectConfigurationDimension,
            IConfigurationDimensionPropertiesAvailableStatus requestedProperties)
        {
            var newProjectConfigurationDimension = new ConfigurationDimensionValue(runtimeModel, new ConfigurationDimensionPropertiesAvailableStatus());

            if (requestedProperties.Name)
            {
                newProjectConfigurationDimension.Name = projectConfigurationDimension.Key;
            }

            if (requestedProperties.Value)
            {
                newProjectConfigurationDimension.Value = projectConfigurationDimension.Value;
            }

            return(newProjectConfigurationDimension);
        }
Ejemplo n.º 7
0
        private IEntityValue CreateLaunchProfileTypeValue(IEntityRuntimeModel entityRuntime, EntityIdentity identity, string commandName, Rule rule)
        {
            LaunchProfileTypeValue newLaunchProfileType = new(entityRuntime, identity, new LaunchProfileTypePropertiesAvailableStatus());

            if (_properties.CommandName)
            {
                newLaunchProfileType.CommandName = commandName;
            }

            if (_properties.DisplayName)
            {
                newLaunchProfileType.DisplayName = rule.DisplayName ?? commandName;
            }

            if (_properties.HelpUrl)
            {
                if (rule.Metadata.TryGetValue("HelpUrl", out object?helpUrlObj) &&
                    helpUrlObj is string helpUrlString)
                {
                    newLaunchProfileType.HelpUrl = helpUrlString;
                }
                else
                {
                    newLaunchProfileType.HelpUrl = string.Empty;
                }
            }

            if (_properties.ImageMoniker)
            {
                if (rule.Metadata.TryGetValue("ImageMonikerGuid", out object?imageMonikerGuidObj) &&
                    imageMonikerGuidObj is Guid imageMonikerGuid &&
                    rule.Metadata.TryGetValue("ImageMonikerId", out object?imageMonikerIdObj) &&
                    imageMonikerIdObj is int imageMonikerId)
                {
                    newLaunchProfileType.ImageMoniker = new ImageMoniker {
                        Guid = imageMonikerGuid, Id = imageMonikerId
                    };
                }
                else
                {
                    newLaunchProfileType.ImageMoniker = KnownMonikers.SettingsGroup;
                }
            }
Ejemplo n.º 8
0
        protected override Task <IEntityValue?> TryCreateEntityOrNullAsync(IEntityRuntimeModel runtimeModel, EntityIdentity id)
        {
            if (id.KeysCount == 4 &&
                id.TryGetValue(ProjectModelIdentityKeys.ProjectPath, out string projectPath) &&
                id.TryGetValue(ProjectModelIdentityKeys.PropertyPageName, out string propertyPageName) &&
                id.TryGetValue(ProjectModelIdentityKeys.UIPropertyName, out string propertyName) &&
                id.TryGetValue(ProjectModelIdentityKeys.EditorName, out string editorName))
            {
                return(UIPropertyEditorDataProducer.CreateEditorValueAsync(
                           runtimeModel,
                           id,
                           _projectService,
                           projectPath,
                           propertyPageName,
                           propertyName,
                           editorName,
                           _properties));
            }

            return(NullEntityValue);
        }
        public static async Task <IEnumerable <IEntityValue> > CreateSupportedValuesAsync(IEntityRuntimeModel runtimeModel, ProjectSystem.Properties.IEnumProperty enumProperty, ISupportedValuePropertiesAvailableStatus requestedProperties)
        {
            ReadOnlyCollection <ProjectSystem.Properties.IEnumValue> enumValues = await enumProperty.GetAdmissibleValuesAsync();

            return(createSupportedValues());

            IEnumerable <IEntityValue> createSupportedValues()
            {
                foreach (ProjectSystem.Properties.IEnumValue value in enumValues)
                {
                    IEntityValue supportedValue = CreateSupportedValue(runtimeModel, value, requestedProperties);
                    yield return(supportedValue);
                }
            }
        }
 public static IEnumerable <IEntityValue> CreateProjectConfigurationDimensions(IEntityRuntimeModel runtimeModel, ProjectConfiguration configuration, IConfigurationDimensionPropertiesAvailableStatus requestedProperties)
 {
     foreach (KeyValuePair <string, string> dimension in configuration.Dimensions)
     {
         IEntityValue projectConfigurationDimension = CreateProjectConfigurationDimension(runtimeModel, dimension, requestedProperties);
         yield return(projectConfigurationDimension);
     }
 }
 protected abstract Task <IEntityValue?> TryCreateEntityOrNullAsync(IEntityRuntimeModel runtimeModel, EntityIdentity id);
        public static IEnumerable <IEntityValue> CreateProjectConfigurationDimensions(IEntityRuntimeModel runtimeModel, 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(runtimeModel, dimension, requestedProperties);
                yield return(projectConfigurationDimension);
            }
        }