/// <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); }
/// <summary> /// Get DAC properties from the DAC extension and its base DAC. /// </summary> /// <param name="dacExtension">The DAC extension to act on.</param> /// <param name="pxContext">Context.</param> /// <param name="dacFields">The DAC fields.</param> /// <param name="cancellation">(Optional) Cancellation token.</param> /// <returns> /// The properties from DAC extension and base DAC. /// </returns> public static OverridableItemsCollection <DacPropertyInfo> GetPropertiesFromDacExtensionAndBaseDac(this ITypeSymbol dacExtension, PXContext pxContext, IDictionary <string, DacFieldInfo> dacFields, CancellationToken cancellation = default) { dacExtension.ThrowOnNull(nameof(dacExtension)); pxContext.ThrowOnNull(nameof(pxContext)); var attributeInformation = new AttributeInformation(pxContext); return(GetPropertiesOrFieldsInfoFromDacExtension <DacPropertyInfo>(dacExtension, pxContext, AddPropertiesFromDac, AddPropertiesFromDacExtension)); //-----------------------Local function---------------------------------------- int AddPropertiesFromDac(OverridableItemsCollection <DacPropertyInfo> propertiesCollection, ITypeSymbol dac, int startingOrder) { var rawDacProperties = dac.GetRawPropertiesFromDacImpl(pxContext, includeFromInheritanceChain: true, cancellation); return(propertiesCollection.AddRangeWithDeclarationOrder(rawDacProperties, startingOrder, (dacProperty, order) => DacPropertyInfo.Create(pxContext, dacProperty.Node, dacProperty.Symbol, order, attributeInformation, dacFields))); } int AddPropertiesFromDacExtension(OverridableItemsCollection <DacPropertyInfo> propertiesCollection, ITypeSymbol dacExt, int startingOrder) { var rawDacExtensionProperties = GetRawPropertiesFromDacOrDacExtensionImpl(dacExt, pxContext, cancellation); return(propertiesCollection.AddRangeWithDeclarationOrder(rawDacExtensionProperties, startingOrder, (dacProperty, order) => DacPropertyInfo.Create(pxContext, dacProperty.Node, dacProperty.Symbol, order, attributeInformation, dacFields))); } }