I implemented Custom Attributes
for enum
using this article, everything is fine with hard coding
values, but I need to pass the parameters in run time
, for example:
enum MyItems{
[CustomEnumAttribute("Products", "en-US", Config.Products)]
Products
}
The Config.Products (bool value)
is the problem, the error is:
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
Is there any way to fix this?
Update
The enum
(MyItems in this case) have 20 items, each item must have that custom attribute
, then I want to generate menu from the Enum's items, depended on Culture
I getting the matched title, also depended on Config
, I decided to show/hide the item from the menu (in fact if Config.X == false, I don't add the item to the menu)
Also, for Config, I have another system and I wanna sync that system with the menu, that is the reason that I wanna get the Config.X
in run-time.
Thanks!