private static OverridableItemsCollection <TInfo> GetViewInfoFromGraphExtension <TInfo>(ITypeSymbol graphExtension, PXContext pxContext,
                                                                                                AddViewInfoWithOrderDelegate <TInfo> addGraphViewInfo,
                                                                                                AddViewInfoWithOrderDelegate <TInfo> addGraphExtensionViewInfo)
            where TInfo : IOverridableItem <TInfo>
        {
            if (!graphExtension.InheritsFrom(pxContext.PXGraphExtensionType) || !graphExtension.BaseType.IsGenericType)
            {
                return(new OverridableItemsCollection <TInfo>());
            }

            var graphType = graphExtension.GetGraphFromGraphExtension(pxContext);

            if (graphType == null)
            {
                return(new OverridableItemsCollection <TInfo>());
            }

            var allExtensionsFromBaseToDerived = graphExtension.GetGraphExtensionWithBaseExtensions(pxContext, SortDirection.Ascending,
                                                                                                    includeGraph: false);

            if (allExtensionsFromBaseToDerived.IsNullOrEmpty())
            {
                return(new OverridableItemsCollection <TInfo>());
            }

            int estimatedCapacity = typeof(TInfo) == typeof(DataViewInfo)
                                ? EstimatedNumberOfViewsInGraph
                                : EstimatedNumberOfViewDelegatesInGraph;

            var infoByView       = new OverridableItemsCollection <TInfo>(capacity: estimatedCapacity);
            int declarationOrder = addGraphViewInfo(infoByView, graphType, startingOrder: 0);

            foreach (ITypeSymbol extension in allExtensionsFromBaseToDerived)
            {
                declarationOrder = addGraphExtensionViewInfo(infoByView, extension, declarationOrder);
            }

            return(infoByView);
        }
Exemple #2
0
        private static IEnumerable <GraphOverridableItem <T> > GetViewInfoFromGraphExtension <T>(ITypeSymbol graphExtension, PXContext pxContext,
                                                                                                 AddViewInfoWithOrderDelegate <T> addGraphViewInfo,
                                                                                                 AddViewInfoWithOrderDelegate <T> addGraphExtensionViewInfo)
        {
            var empty = Enumerable.Empty <GraphOverridableItem <T> >();

            if (!graphExtension.InheritsFrom(pxContext.PXGraphExtensionType) || !graphExtension.BaseType.IsGenericType)
            {
                return(empty);
            }

            var graphType = graphExtension.GetGraphFromGraphExtension(pxContext);

            if (graphType == null)
            {
                return(empty);
            }

            var allExtensionsFromBaseToDerived = graphExtension.GetGraphExtensionWithBaseExtensions(pxContext, SortDirection.Ascending,
                                                                                                    includeGraph: false);

            if (allExtensionsFromBaseToDerived.IsNullOrEmpty())
            {
                return(empty);
            }

            var infoByView       = new GraphOverridableItemsCollection <T>();
            int declarationOrder = addGraphViewInfo(infoByView, graphType, startingOrder: 0);

            foreach (ITypeSymbol extension in allExtensionsFromBaseToDerived)
            {
                declarationOrder = addGraphExtensionViewInfo(infoByView, extension, declarationOrder);
            }

            return(infoByView.Items);
        }