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); }
private ImmutableDictionary <string, GraphFieldEventInfo> GetFieldEvents(EventsCollector eventsCollector, EventType eventType) { if (Type == GraphType.None) { return(ImmutableDictionary.Create <string, GraphFieldEventInfo>()); } OverridableItemsCollection <GraphFieldEventInfo> rawCollection = eventsCollector.GetFieldEvents(eventType); return(rawCollection.ToImmutableDictionary() ?? ImmutableDictionary.Create <string, GraphFieldEventInfo>()); }
/// <summary> /// Gets all declared view symbols and types from the graph and its base graphs, /// if there is a graphs class hierarchy and <paramref name="includeViewsFromInheritanceChain"/> parameter is <c>true</c>. /// </summary> /// <param name="graph">The graph to act on.</param> /// <param name="pxContext">Context.</param> /// <param name="includeViewsFromInheritanceChain">(Optional) True to include, false to exclude the views from inheritance chain.</param> /// <returns/> public static OverridableItemsCollection <DataViewInfo> GetViewsWithSymbolsFromPXGraph(this ITypeSymbol graph, PXContext pxContext, bool includeViewsFromInheritanceChain = true) { pxContext.ThrowOnNull(nameof(pxContext)); if (graph?.InheritsFrom(pxContext.PXGraph.Type) != true) { return(new OverridableItemsCollection <DataViewInfo>()); } var viewsByName = new OverridableItemsCollection <DataViewInfo>(capacity: EstimatedNumberOfViewsInGraph); var graphViews = GetRawViewsFromGraphImpl(graph, pxContext, includeViewsFromInheritanceChain); viewsByName.AddRangeWithDeclarationOrder(graphViews, startingOrder: 0, (view, order) => new DataViewInfo(view.ViewSymbol, view.ViewType, pxContext, order)); return(viewsByName); }
/// <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); }
/// <summary> /// Get the action handlers method symbols and syntax nodes from the graph. The <paramref name="actionsByName"/> must have <see cref="StringComparer.OrdinalIgnoreCase"/> comparer. /// </summary> /// <param name="graph">The graph to act on.</param> /// <param name="actionsByName">The actions of the graph dictionary with <see cref="StringComparer.OrdinalIgnoreCase"/> comparer.</param> /// <param name="pxContext">Context.</param> /// <param name="inheritance">(Optional) If true includes action handlers from the graph inheritance chain.</param> /// <param name="cancellation">(Optional) Cancellation token.</param> /// <returns> /// The action handlers from graph. /// </returns> public static OverridableItemsCollection <ActionHandlerInfo> GetActionHandlersFromGraph(this ITypeSymbol graph, IDictionary <string, ActionInfo> actionsByName, PXContext pxContext, bool inheritance = true, CancellationToken cancellation = default) { graph.ThrowOnNull(nameof(graph)); actionsByName.ThrowOnNull(nameof(actionsByName)); pxContext.ThrowOnNull(nameof(pxContext)); if (!graph.IsPXGraph(pxContext)) { return(new OverridableItemsCollection <ActionHandlerInfo>()); } var actionHandlersByName = new OverridableItemsCollection <ActionHandlerInfo>(capacity: EstimatedNumberOfActionsInGraph); var graphHandlers = GetRawActionHandlersFromGraphImpl(graph, actionsByName, pxContext, cancellation, inheritance); actionHandlersByName.AddRangeWithDeclarationOrder(graphHandlers, startingOrder: 0, (hander, order) => new ActionHandlerInfo(hander.Node, hander.Symbol, order)); return(actionHandlersByName); }
/// <summary> /// Get the DAC fields symbols and syntax nodes from the DAC. /// </summary> /// <param name="dac">The DAC to act on.</param> /// <param name="pxContext">Context.</param> /// <param name="includeFromInheritanceChain">(Optional) True to include, false to exclude the DAC fields from the inheritance chain.</param> /// <param name="cancellation">(Optional) Cancellation token.</param> /// <returns> /// The DAC fields from DAC. /// </returns> public static OverridableItemsCollection <DacFieldInfo> GetDacFieldsFromDac(this ITypeSymbol dac, PXContext pxContext, bool includeFromInheritanceChain = true, CancellationToken cancellation = default) { dac.ThrowOnNull(nameof(dac)); pxContext.ThrowOnNull(nameof(pxContext)); if (!dac.IsDAC(pxContext)) { return(new OverridableItemsCollection <DacFieldInfo>()); } int estimatedCapacity = dac.GetTypeMembers().Length; var dacFieldsByName = new OverridableItemsCollection <DacFieldInfo>(estimatedCapacity); var dacFields = GetRawDacFieldsFromDacImpl(dac, pxContext, includeFromInheritanceChain, cancellation); dacFieldsByName.AddRangeWithDeclarationOrder(dacFields, startingOrder: 0, (dacField, order) => new DacFieldInfo(dacField.Node, dacField.Symbol, order)); return(dacFieldsByName); }
/// <summary> /// Get the view delegates symbols and syntax nodes from the graph. The <paramref name="viewsByName"/> must have <see cref="StringComparer.OrdinalIgnoreCase"/> comparer. /// </summary> /// <param name="graph">The graph to act on.</param> /// <param name="viewsByName">The views of the graph dictionary with <see cref="StringComparer.OrdinalIgnoreCase"/> comparer.</param> /// <param name="pxContext">Context.</param> /// <param name="inheritance">(Optional) If true includes view delegates from the graph inheritance chain.</param> /// <param name="cancellation">(Optional) Cancellation token.</param> /// <returns> /// The view delegates from graph. /// </returns> public static OverridableItemsCollection <DataViewDelegateInfo> GetViewDelegatesFromGraph(this ITypeSymbol graph, IDictionary <string, DataViewInfo> viewsByName, PXContext pxContext, bool inheritance = true, CancellationToken cancellation = default) { graph.ThrowOnNull(nameof(graph)); viewsByName.ThrowOnNull(nameof(viewsByName)); pxContext.ThrowOnNull(nameof(pxContext)); if (!graph.IsPXGraph(pxContext)) { return(new OverridableItemsCollection <DataViewDelegateInfo>()); } var viewDelegatesByName = new OverridableItemsCollection <DataViewDelegateInfo>(capacity: EstimatedNumberOfViewDelegatesInGraph); var graphViewDelegates = GetRawViewDelegatesFromGraphImpl(graph, viewsByName, pxContext, inheritance, cancellation); viewDelegatesByName.AddRangeWithDeclarationOrder(graphViewDelegates, startingOrder: 0, (viewDel, order) => new DataViewDelegateInfo(viewDel.Node, viewDel.Symbol, order)); return(viewDelegatesByName); }
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); }
/// <summary> /// Gets the DAC property symbols and syntax nodes from DAC and, if <paramref name="includeFromInheritanceChain"/> is <c>true</c>, its base DACs. /// </summary> /// <param name="dac">The DAC to act on.</param> /// <param name="pxContext">Context.</param> /// <param name="dacFields">The DAC fields.</param> /// <param name="includeFromInheritanceChain">(Optional) True to include, false to exclude the properties from the inheritance chain.</param> /// <param name="cancellation">(Optional) Cancellation token.</param> /// <returns> /// The DAC property symbols with nodes from DAC. /// </returns> public static OverridableItemsCollection <DacPropertyInfo> GetDacPropertiesFromDac(this ITypeSymbol dac, PXContext pxContext, IDictionary <string, DacFieldInfo> dacFields, bool includeFromInheritanceChain = true, CancellationToken cancellation = default) { pxContext.ThrowOnNull(nameof(pxContext)); dacFields.ThrowOnNull(nameof(dacFields)); if (!dac.IsDAC(pxContext)) { return(new OverridableItemsCollection <DacPropertyInfo>()); } int estimatedCapacity = dac.GetTypeMembers().Length; var propertiesByName = new OverridableItemsCollection <DacPropertyInfo>(estimatedCapacity); var dacProperties = GetRawPropertiesFromDacImpl(dac, pxContext, includeFromInheritanceChain, cancellation); var attributeInformation = new AttributeInformation(pxContext); propertiesByName.AddRangeWithDeclarationOrder(dacProperties, startingOrder: 0, (rawData, order) => DacPropertyInfo.Create(pxContext, rawData.Node, rawData.Symbol, order, attributeInformation, dacFields)); return(propertiesByName); }
private static OverridableItemsCollection <TInfo> GetPropertiesOrFieldsInfoFromDacExtension <TInfo>(ITypeSymbol dacExtension, PXContext pxContext, AddDacPropertyInfoWithOrderDelegate <TInfo> addDacPropertyInfoWithOrder, AddDacPropertyInfoWithOrderDelegate <TInfo> addDacExtensionPropertyInfoWithOrder) where TInfo : IOverridableItem <TInfo> { if (!dacExtension.IsDacExtension(pxContext)) { return(new OverridableItemsCollection <TInfo>()); } var dacType = dacExtension.GetDacFromDacExtension(pxContext); if (dacType == null) { return(new OverridableItemsCollection <TInfo>()); } var allExtensionsFromBaseToDerived = dacExtension.GetDacExtensionWithBaseExtensions(pxContext, SortDirection.Ascending, includeDac: false); if (allExtensionsFromBaseToDerived.IsNullOrEmpty()) { return(new OverridableItemsCollection <TInfo>()); } int estimatedCapacity = dacType.GetTypeMembers().Length; var propertiesByName = new OverridableItemsCollection <TInfo>(estimatedCapacity); int declarationOrder = addDacPropertyInfoWithOrder(propertiesByName, dacType, startingOrder: 0); foreach (ITypeSymbol extension in allExtensionsFromBaseToDerived) { declarationOrder = addDacExtensionPropertyInfoWithOrder(propertiesByName, extension, declarationOrder); } return(propertiesByName); }