コード例 #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        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);
        }
コード例 #2
0
        public async Task <IRule> GetRuleAsync(IDependency dependency, IProjectCatalogSnapshot catalogs)
        {
            Requires.NotNull(dependency, nameof(dependency));

            ConfiguredProject project = null;

            if (dependency.TargetFramework.Equals(TargetFramework.Any))
            {
                project = ActiveConfiguredProject;
            }
            else
            {
                project = await DependenciesHost.GetConfiguredProject(dependency.TargetFramework)
                          .ConfigureAwait(false) ?? ActiveConfiguredProject;
            }

            ConfiguredProjectExports configuredProjectExports = GetActiveConfiguredProjectExports(project);
            IImmutableDictionary <string, IPropertyPagesCatalog> namedCatalogs = await GetNamedCatalogsAsync(catalogs).ConfigureAwait(false);

            Requires.NotNull(namedCatalogs, nameof(namedCatalogs));

            IPropertyPagesCatalog browseObjectsCatalog = namedCatalogs[PropertyPageContexts.BrowseObject];
            Rule   schema   = browseObjectsCatalog.GetSchema(dependency.SchemaName);
            string itemSpec = string.IsNullOrEmpty(dependency.OriginalItemSpec) ? dependency.Path : dependency.OriginalItemSpec;
            var    context  = ProjectPropertiesContext.GetContext(UnconfiguredProject,
                                                                  itemType: dependency.SchemaItemType,
                                                                  itemName: itemSpec);

            IRule rule = null;

            if (schema != null)
            {
                if (dependency.Resolved)
                {
                    rule = configuredProjectExports.RuleFactory.CreateResolvedReferencePageRule(
                        schema,
                        context,
                        dependency.Name,
                        dependency.Properties);
                }
                else
                {
                    rule = browseObjectsCatalog.BindToContext(schema.Name, context);
                }
            }
            else
            {
                // Since we have no browse object, we still need to create *something* so
                // that standard property pages can pop up.
                Rule emptyRule = RuleExtensions.SynthesizeEmptyRule(context.ItemType);
                return(configuredProjectExports.PropertyPagesDataModelProvider.GetRule(
                           emptyRule,
                           context.File,
                           context.ItemType,
                           context.ItemName));
            }

            return(rule);
        }
コード例 #3
0
        public async Task <IRule> GetRuleAsync(IDependency dependency, IProjectCatalogSnapshot catalogs)
        {
            Requires.NotNull(dependency, nameof(dependency));

            ConfiguredProject project = dependency.TargetFramework.Equals(TargetFramework.Any)
                ? ActiveConfiguredProject
                : _dependenciesHost.GetConfiguredProject(dependency.TargetFramework) ?? ActiveConfiguredProject;

            IImmutableDictionary <string, IPropertyPagesCatalog> namedCatalogs = await GetNamedCatalogsAsync();

            Requires.NotNull(namedCatalogs, nameof(namedCatalogs));

            IPropertyPagesCatalog browseObjectsCatalog = namedCatalogs[PropertyPageContexts.BrowseObject];
            Rule   schema   = browseObjectsCatalog.GetSchema(dependency.SchemaName);
            string itemSpec = string.IsNullOrEmpty(dependency.OriginalItemSpec) ? dependency.Path : dependency.OriginalItemSpec;
            var    context  = ProjectPropertiesContext.GetContext(UnconfiguredProject,
                                                                  itemType: dependency.SchemaItemType,
                                                                  itemName: itemSpec);

            if (schema == null)
            {
                // Since we have no browse object, we still need to create *something* so
                // that standard property pages can pop up.
                Rule emptyRule = RuleExtensions.SynthesizeEmptyRule(context.ItemType);
                return(GetActiveConfiguredProjectExports(project).PropertyPagesDataModelProvider.GetRule(
                           emptyRule,
                           context.File,
                           context.ItemType,
                           context.ItemName));
            }

            if (dependency.Resolved)
            {
                return(GetActiveConfiguredProjectExports(project).RuleFactory.CreateResolvedReferencePageRule(
                           schema,
                           context,
                           dependency.Name,
                           dependency.Properties));
            }

            return(browseObjectsCatalog.BindToContext(schema.Name, context));

            async Task <IImmutableDictionary <string, IPropertyPagesCatalog> > GetNamedCatalogsAsync()
            {
                if (catalogs != null)
                {
                    return(catalogs.NamedCatalogs);
                }

                if (_namedCatalogs == null)
                {
                    // Note: it is unlikely that we end up here, however for cases when node providers
                    // getting their node data not from Design time build events, we might have OnDependenciesChanged
                    // event coming before initial design time build event updates NamedCatalogs in this class.
                    // Thus, just in case, explicitly request it here (GetCatalogsAsync will acquire a project read lock)
                    _namedCatalogs = await ActiveConfiguredProject.Services
                                     .PropertyPagesCatalog
                                     .GetCatalogsAsync(CancellationToken.None);
                }

                return(_namedCatalogs);
            }
        }