private static OverridableItemsCollection <TInfo> GetActionInfoFromGraphExtension <TInfo>(ITypeSymbol graphExtension, PXContext pxContext,
                                                                                                  AddActionInfoWithOrderDelegate <TInfo> addGraphActionInfoWithOrder,
                                                                                                  AddActionInfoWithOrderDelegate <TInfo> addGraphExtensionActionInfoWithOrder)
            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>());
            }

            var actionsByName    = new OverridableItemsCollection <TInfo>(capacity: EstimatedNumberOfActionsInGraph);
            int declarationOrder = addGraphActionInfoWithOrder(actionsByName, graphType, startingOrder: 0);

            foreach (ITypeSymbol extension in allExtensionsFromBaseToDerived)
            {
                declarationOrder = addGraphExtensionActionInfoWithOrder(actionsByName, extension, declarationOrder);
            }

            return(actionsByName);
        }
Example #2
0
        private static IEnumerable <GraphOverridableItem <T> > GetActionInfoFromGraphExtension <T>(ITypeSymbol graphExtension, PXContext pxContext,
                                                                                                   AddActionInfoWithOrderDelegate <T> addGraphActionInfoWithOrder,
                                                                                                   AddActionInfoWithOrderDelegate <T> addGraphExtensionActionInfoWithOrder)
        {
            var empty = Enumerable.Empty <GraphOverridableItem <T> >();

            if (!graphExtension.InheritsFrom(pxContext.PXGraphExtensionType) || !graphExtension.BaseType.IsGenericType)
            {
                return(Enumerable.Empty <GraphOverridableItem <T> >());
            }

            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 actionsByName    = new GraphOverridableItemsCollection <T>();
            int declarationOrder = addGraphActionInfoWithOrder(actionsByName, graphType, startingOrder: 0);

            foreach (ITypeSymbol extension in allExtensionsFromBaseToDerived)
            {
                declarationOrder = addGraphExtensionActionInfoWithOrder(actionsByName, extension, declarationOrder);
            }

            return(actionsByName.Items);
        }