Skip to content

Is it possible to use an aspect several times on the same type? #99

Answered by svick
YBAZAN asked this question in Q&A
Discussion options

You must be logged in to vote

Is it possible to use an aspect several times on the same type?

Yes, by accessing builder.AspectInstance.SecondaryInstances. For example, like this:

public override void BuildAspect(IAspectBuilder<INamedType> builder)
{
    base.BuildAspect(builder);

    this.BuildAspectInstance(builder);

    foreach (var instance in builder.AspectInstance.SecondaryInstances)
    {
        ((StyledPropertyAttribute)instance.Aspect).BuildAspectInstance(builder);
    }
}

private void BuildAspectInstance(IAspectBuilder<INamedType> builder)
{
    // your original BuildAspect code here
}

is it possible to introduce a field with the readonly keyword?

Yes, if you use a template field, e.g.:

[Template]
pri…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by svick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants