You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
using System; |
|
|
|
namespace NaughtyAttributes |
|
{ |
|
public abstract class EnableIfAttributeBase : MetaAttribute |
|
{ |
|
public string[] Conditions { get; private set; } |
|
public EConditionOperator ConditionOperator { get; private set; } |
|
public bool Inverted { get; protected set; } |
|
|
|
/// <summary> |
|
/// If this not null, <see cref="Conditions"/>[0] is name of an enum variable. |
|
/// </summary> |
|
public Enum EnumValue { get; private set; } |
|
|
|
public EnableIfAttributeBase(string condition) |
|
{ |
|
ConditionOperator = EConditionOperator.And; |
|
Conditions = new string[1] { condition }; |
|
} |
|
|
|
public EnableIfAttributeBase(EConditionOperator conditionOperator, params string[] conditions) |
|
{ |
|
ConditionOperator = conditionOperator; |
|
Conditions = conditions; |
|
} |
|
|
|
public EnableIfAttributeBase(string enumName, Enum enumValue) |
|
: this(enumName) |
|
{ |
|
if (enumValue == null) |
|
{ |
|
throw new ArgumentNullException(nameof(enumValue), "This parameter must be an enum value."); |
|
} |
|
|
|
EnumValue = enumValue; |
|
} |
|
} |
|
}
|
|
|