Try our conversational search powered by Generative AI!

What is the role of AllowMultiple=true/false?

Vote:
 

What is the role of AllowMultiple when we already inherit from SelectOneAttribute?

[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class LanguageSelectionAttribute : SelectOneAttribute
{
    public override Type SelectionFactoryType
    {
        get
        {
            return typeof(LanguageSelectionFactory);
        }
        set
        {
            base.SelectionFactoryType = value;
        }
    }
}

#202289
Mar 22, 2019 5:14
Vote:
 

it has nothing to do with the Episerver, but actually prevents you to write code like following:

[ContentType]
public class SamplePage : PageData
{
    [LanguageSelection]
    [LanguageSelection]
    public virtual string SingleLanguage { get; set; }
}

because having multiple attributes on the same property does not make sense in this context.

#202290
Mar 22, 2019 6:31
Vote:
 

To extend valdis's answer: that's a .NET framework thing and not Episerver specific, and it's to indicate that if you want to allow callers to apply your attributes multiple times or not.

One example is the lifecyle attribute, it should not be both Singleton AND Transient, so you would want it to be apply one time. But if you want a specific feature to be accessible only to people with two roles - they have to be both CommerceAdmins and EPiBetaUsers, for example, it's when you apply the Authorize attribute two times 

#202291
Mar 22, 2019 7:31
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.