| | | 1 | | namespace NexusLabs.Needlr; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Specifies the execution order for a plugin. Lower values execute first. |
| | | 5 | | /// Plugins without this attribute default to Order = 0. |
| | | 6 | | /// </summary> |
| | | 7 | | /// <remarks> |
| | | 8 | | /// <para> |
| | | 9 | | /// Use this attribute to control the order in which plugins are executed. |
| | | 10 | | /// This is useful when plugins have dependencies on each other or when |
| | | 11 | | /// certain plugins must run before or after others. |
| | | 12 | | /// </para> |
| | | 13 | | /// <para> |
| | | 14 | | /// Example usage: |
| | | 15 | | /// <code> |
| | | 16 | | /// // Infrastructure plugins run first (negative order) |
| | | 17 | | /// [PluginOrder(-100)] |
| | | 18 | | /// public class DatabaseMigrationPlugin : IServiceCollectionPlugin { } |
| | | 19 | | /// |
| | | 20 | | /// // Default order (0) - no attribute needed |
| | | 21 | | /// public class BusinessLogicPlugin : IServiceCollectionPlugin { } |
| | | 22 | | /// |
| | | 23 | | /// // Validation plugins run last (positive order) |
| | | 24 | | /// [PluginOrder(100)] |
| | | 25 | | /// public class ValidationPlugin : IServiceCollectionPlugin { } |
| | | 26 | | /// </code> |
| | | 27 | | /// </para> |
| | | 28 | | /// <para> |
| | | 29 | | /// When multiple plugins have the same order, they are sorted alphabetically |
| | | 30 | | /// by their fully qualified type name to ensure deterministic execution order. |
| | | 31 | | /// </para> |
| | | 32 | | /// </remarks> |
| | | 33 | | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] |
| | | 34 | | public sealed class PluginOrderAttribute : Attribute |
| | | 35 | | { |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets the execution order. Lower values execute first. |
| | | 38 | | /// </summary> |
| | 820 | 39 | | public int Order { get; } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Initializes a new instance of <see cref="PluginOrderAttribute"/> with the specified order. |
| | | 43 | | /// </summary> |
| | | 44 | | /// <param name="order"> |
| | | 45 | | /// The execution order. Lower values execute first. |
| | | 46 | | /// Negative values run before default (0), positive values run after. |
| | | 47 | | /// </param> |
| | 6560 | 48 | | public PluginOrderAttribute(int order) => Order = order; |
| | | 49 | | } |