Beispiel #1
0
        public static async Task <IEntityValue?> CreatePropertyPageValueAsync(
            IQueryExecutionContext queryExecutionContext,
            EntityIdentity id,
            IProjectService2 projectService,
            QueryProjectPropertiesContext propertiesContext,
            string propertyPageName,
            IPropertyPagePropertiesAvailableStatus requestedProperties)
        {
            if (projectService.GetLoadedProject(propertiesContext.File) is UnconfiguredProject project)
            {
                // TODO: Go through the IProjectState to get this
                project.GetQueryDataVersion(out string versionKey, out long versionNumber);
                queryExecutionContext.ReportInputDataVersion(versionKey, versionNumber);

                if (await project.GetProjectLevelPropertyPagesCatalogAsync() is IPropertyPagesCatalog projectCatalog &&
                    projectCatalog.GetSchema(propertyPageName) is { PropertyPagesHidden : false } rule)
                {
                    IProjectState projectState      = new PropertyPageProjectState(project);
                    IEntityValue  propertyPageValue = CreatePropertyPageValue(queryExecutionContext, id, projectState, propertiesContext, rule, requestedProperties);
                    return(propertyPageValue);
                }
            }

            return(null);
        }
        public static async Task <IEnumerable <IEntityValue> > CreatePropertyPageValuesAsync(
            IQueryExecutionContext queryExecutionContext,
            IEntityValue parent,
            UnconfiguredProject project,
            IPropertyPagePropertiesAvailableStatus requestedProperties)
        {
            if (await project.GetProjectLevelPropertyPagesCatalogAsync() is IPropertyPagesCatalog projectCatalog)
            {
                return(createPropertyPageValuesAsync());
            }

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

            IEnumerable <IEntityValue> createPropertyPageValuesAsync()
            {
                IProjectState projectState = new PropertyPageProjectState(project);
                QueryProjectPropertiesContext propertiesContext = new QueryProjectPropertiesContext(isProjectFile: true, project.FullPath, itemType: null, itemName: null);

                foreach (string schemaName in projectCatalog.GetProjectLevelPropertyPagesSchemas())
                {
                    if (projectCatalog.GetSchema(schemaName) is Rule rule &&
                        !rule.PropertyPagesHidden)
                    {
                        IEntityValue propertyPageValue = CreatePropertyPageValue(queryExecutionContext, parent, projectState, propertiesContext, rule, requestedProperties: requestedProperties);
                        yield return(propertyPageValue);
                    }
                }
            }
        }
Beispiel #3
0
        public static async Task <IEnumerable <IEntityValue> > CreatePropertyPageValuesAsync(
            IQueryExecutionContext queryExecutionContext,
            IEntityValue parent,
            UnconfiguredProject project,
            IPropertyPagePropertiesAvailableStatus requestedProperties)
        {
            if (await project.GetProjectLevelPropertyPagesCatalogAsync() is IPropertyPagesCatalog projectCatalog)
            {
                return(createPropertyPageValuesAsync());
            }

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

            IEnumerable <IEntityValue> createPropertyPageValuesAsync()
            {
                IProjectState projectState = new PropertyPageProjectState(project);
                QueryProjectPropertiesContext propertiesContext = new QueryProjectPropertiesContext(isProjectFile: true, project.FullPath, itemType: null, itemName: null);

                foreach (string schemaName in projectCatalog.GetProjectLevelPropertyPagesSchemas())
                {
                    if (projectCatalog.GetSchema(schemaName) is Rule rule &&
                        !rule.PropertyPagesHidden)
                    {
                        if (rule.Name == "RazorGeneral" || rule.Name == "RazorExtension")
                        {
                            // Some versions of the .NET SDK include a Razor property page that appears
                            // in the UI. This page is not intended for display.
                            //
                            // We cannot remove this page from existing versions of the SDK, so have to
                            // explicitly exclude it from query results so that it doesn't appear in any
                            // UI.

                            continue;
                        }

                        IEntityValue propertyPageValue = CreatePropertyPageValue(queryExecutionContext, parent, projectState, propertiesContext, rule, requestedProperties: requestedProperties);
                        yield return(propertyPageValue);
                    }
                }
            }
        }