/// <summary> /// Get all action symbols and types from the graph extension and its base graph /// </summary> /// <param name="graphExtension">The graph extension to act on</param> /// <param name="pxContext">Context</param> /// <returns/> public static OverridableItemsCollection <ActionInfo> GetActionsFromGraphExtensionAndBaseGraph(this ITypeSymbol graphExtension, PXContext pxContext) { graphExtension.ThrowOnNull(nameof(graphExtension)); pxContext.ThrowOnNull(nameof(pxContext)); var systemActionsRegister = new PXSystemActions.PXSystemActionsRegister(pxContext); return(GetActionInfoFromGraphExtension <ActionInfo>(graphExtension, pxContext, AddActionsFromGraph, AddActionsFromGraphExtension)); int AddActionsFromGraph(OverridableItemsCollection <ActionInfo> actionsCollection, ITypeSymbol graph, int startingOrder) { var graphActions = graph.GetRawActionsFromGraphImpl(pxContext, includeActionsFromInheritanceChain: true); return(actionsCollection.AddRangeWithDeclarationOrder(graphActions, startingOrder, (action, order) => new ActionInfo(action.ActionSymbol, action.ActionType, order, systemActionsRegister.IsSystemAction(action.ActionType)))); } int AddActionsFromGraphExtension(OverridableItemsCollection <ActionInfo> actionsCollection, ITypeSymbol graphExt, int startingOrder) { var extensionActions = GetRawActionsFromGraphOrGraphExtensionImpl(graphExt, pxContext); return(actionsCollection.AddRangeWithDeclarationOrder(extensionActions, startingOrder, (action, order) => new ActionInfo(action.ActionSymbol, action.ActionType, order, systemActionsRegister.IsSystemAction(action.ActionType)))); } }
private ImmutableDictionary <string, ActionInfo> GetActions() { if (Type == GraphType.None) { return(ImmutableDictionary.Create <string, ActionInfo>(StringComparer.OrdinalIgnoreCase)); } var systemActionsRegister = new PXSystemActions.PXSystemActionsRegister(_pxContext); var rawActionInfos = Type == GraphType.PXGraph ? Symbol.GetActionSymbolsWithTypesFromGraph(_pxContext) : Symbol.GetActionsFromGraphExtensionAndBaseGraph(_pxContext); return(rawActionInfos.ToLookup(a => a.Item.ActionSymbol.Name, StringComparer.OrdinalIgnoreCase) .ToImmutableDictionary(group => group.Key, group => CreateActionInfo(group.First()), keyComparer: StringComparer.OrdinalIgnoreCase)); ActionInfo CreateActionInfo(GraphOverridableItem <(ISymbol ActionSymbol, INamedTypeSymbol ActionType)> item) { var(actionSymbol, actionType) = item.Item; ActionInfo baseActionInfo = item.Base != null ? CreateActionInfo(item.Base) : null; return(baseActionInfo == null ? new ActionInfo(actionSymbol, actionType, item.DeclarationOrder, systemActionsRegister.IsSystemAction(actionType)) : new ActionInfo(actionSymbol, actionType, item.DeclarationOrder, systemActionsRegister.IsSystemAction(actionType), baseActionInfo)); } }
/// <summary> /// Gets the PXAction symbols with types from graph and, if <paramref name="includeActionsFromInheritanceChain"/> is <c>true</c>, its base graphs. /// </summary> /// <param name="graph">The graph to act on.</param> /// <param name="pxContext">Context.</param> /// <param name="includeActionsFromInheritanceChain">(Optional) True to include, false to exclude the actions from the inheritance chain.</param> /// <returns/> public static OverridableItemsCollection <ActionInfo> GetActionSymbolsWithTypesFromGraph(this ITypeSymbol graph, PXContext pxContext, bool includeActionsFromInheritanceChain = true) { pxContext.ThrowOnNull(nameof(pxContext)); if (!graph.IsPXGraph(pxContext)) { return(new OverridableItemsCollection <ActionInfo>()); } var actionsByName = new OverridableItemsCollection <ActionInfo>(capacity: EstimatedNumberOfActionsInGraph); var graphActions = GetRawActionsFromGraphImpl(graph, pxContext, includeActionsFromInheritanceChain); var systemActionsRegister = new PXSystemActions.PXSystemActionsRegister(pxContext); actionsByName.AddRangeWithDeclarationOrder(graphActions, startingOrder: 0, (action, order) => new ActionInfo(action.ActionSymbol, action.ActionType, order, systemActionsRegister.IsSystemAction(action.ActionType))); return(actionsByName); }