Skip to content

Add the ability to prioritize decorators #255

Description

@ipjohnson

Current you can prioritize exports but you can't prioritize decorators. It should be easy enough to add a fluent configuration method to allow this.

This was brought up in issue #253

Activity

  1. ipjohnson commented on Apr 4, 2020

    @ipjohnson
    OwnerAuthor

    This is implemented

  2. shahabganji commented on Apr 5, 2020

    @shahabganji

    @ipjohnson thanks for this feature 🙏

    Priority method overrides the order of decorators registrations. This is still globally ordering the decorators and one cannot customize it per implementations, right?

    Consider the following rare scenario:

    public interface ICommand<T>{
        void Handle(T data);
    }
    
    [Audit]
    [Log]
    public class FirstCommand: ICommand<string> { ... } 
    
    
    [Database]
    [Log]
    [Audit]
    public class SecondCommand: ICommand<string>{ ... }

    And there are three other decorators implementing the ICommand<T> and with .When.MeetsCondition, an example discussed earlier, they have been customized to be created on the existence of the corresponding attribute on top of the implementations. Is there any way that the order of decorators being based on the order of attributes? For instance, when creating decorators for FirstCommand the order be Audit -> Log but for the SecondCommand it should be the other way: Database -> Log -> Audit.

    is it at all possible and reasonable?

    Thanks.

  3. ipjohnson commented on Apr 5, 2020

    @ipjohnson
    OwnerAuthor

    Sadly attribute order is not preserved as part of the language specification.

    "The order in which attributes are specified in such a list, and the order in which sections attached to the same program entity are arranged, is not significant. For instance, the attribute specifications [A][B], [B][A], [A,B], and [B,A] are equivalent."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions