//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public Dictionary <string, string> ProjectPropertiesToDictionary() { Dictionary <string, string> evaluatedProperties = new Dictionary <string, string> (); IPropertyPagesCatalog projectPropertyList = ConfiguredProject.Services.PropertyPagesCatalog.GetCatalog("Project"); IEnumerable <string> projectPropertySchemas = projectPropertyList.GetPropertyPagesSchemas(); foreach (string schema in projectPropertySchemas) { IRule schemaRules = projectPropertyList.BindToContext(schema, File, ItemType, ItemName); foreach (IProperty properties in schemaRules.Properties) { try { IEvaluatedProperty evaluatedProperty = (IEvaluatedProperty)properties; string schemaGroupedKey = schema + "." + properties.Name; evaluatedProperties [schemaGroupedKey] = evaluatedProperty.EvaluatedValueAtEnd; } catch (Exception e) { LoggingUtils.HandleException(e); } } } return(evaluatedProperties); }
private string GetValueAtEnd(Func <ConfigurationGeneral, IEvaluatedProperty> func) { return(_threadingService.ExecuteSynchronously(async() => { ConfigurationGeneral configurationGeneral = await _projectProperties.Value.GetConfigurationGeneralPropertiesAsync(); IEvaluatedProperty evaluatedProperty = func(configurationGeneral); return await evaluatedProperty.GetEvaluatedValueAtEndAsync(); })); }
private void SetValue(Func <ConfigurationGeneral, IEvaluatedProperty> func, object value) { _threadingService.ExecuteSynchronously(async() => { ConfigurationGeneral configurationGeneral = await _projectProperties.Value.GetConfigurationGeneralPropertiesAsync(); IEvaluatedProperty evaluatedProperty = func(configurationGeneral); await evaluatedProperty.SetValueAsync(value); }); }
private T GetBrowseObjectValue <T>(Func <ConfigurationGeneralBrowseObject, IEvaluatedProperty> func) { return(_threadingService.ExecuteSynchronously(async() => { ConfigurationGeneralBrowseObject browseObject = await _projectProperties.Value.GetConfigurationGeneralBrowseObjectPropertiesAsync(); IEvaluatedProperty evaluatedProperty = func(browseObject); object?value = await evaluatedProperty.GetValueAsync(); // IEvaluatedProperty.GetValueAsync always returns a non-null value, though // it inherits this method from IProperty which can return null. return (T)value !; })); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public async Task <Dictionary <string, string> > ProjectPropertiesToDictionary() { LoggingUtils.PrintFunction(); Dictionary <string, string> evaluatedProperties = new Dictionary <string, string> (); var catalogs = await GetNamedCatalogsAsync(); foreach (var catalog in catalogs) { IReadOnlyCollection <string> catalogPropertySchemas = catalog.Value.GetPropertyPagesSchemas(); foreach (string schema in catalogPropertySchemas) { IRule schemaRules = catalog.Value.BindToContext(schema, File, ItemType, ItemName); foreach (IProperty property in schemaRules.Properties) { try { if (property.DataSource.Persistence.Equals("ProjectInstance")) { // Exceptions are thrown when trying to query the values of properties with 'ProjectInstance' persistence. continue; } IEvaluatedProperty evaluatedProperty = (IEvaluatedProperty)property; string schemaGroupedKey = schema + "." + property.Name; evaluatedProperties [schemaGroupedKey] = await evaluatedProperty.GetEvaluatedValueAsync(); } catch (Exception e) { LoggingUtils.HandleException(e); } } } } return(evaluatedProperties); }