I want to use my IsGPUBasedAttribute
for enum members like this:
public enum EffectType
{
[IsGPUBased(true)]
PixelShader,
[IsGPUBas
There isn't a way to specify that an attribute can be used only on enum members. Honestly, you're probably better off creating your own Effect
(or EffectType
) class and implementing these as ordinary properties if you're going to have multiple attributes like this.
For example,
public class EffectType
{
public bool IsGpuBased { get; private set; }
private EffectType(bool isGpuBased)
{
IsGpuBased = isGpuBased;
}
public static readonly EffectType PixelShader = new EffectType(true);
public static readonly EffectType Blur = new EffectType(false);
}
Taking this approach will give you code that's both easier to read and will perform better compared to metadata extraction.