We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
At a glance, I'm not seeing a method of using an enum along with EnumeratedValueArgument, specifically when using a attribute style parsing target.
enum
EnumeratedValueArgument
I was hoping for something like:
public enum MyEnum { One, Two } [EnumeratedValueArgument(typeof(MyEnum), 'm', "myEnum")] public MyEnum ParsedEnum;
or perhaps:
public enum MyEnum { One, Two } public static Dictionary<MyEnum, string> EnumMapping = new Dictionary<MyEnum, string>() { { MyEnum.One, "do something with one" }, { MyEnum.Two, "do something with two" }, }; [EnumeratedValueArgument(typeof(string), 'm', "myEnum", AllowedValues = string.Join(";", EnumMapping.Keys)] public string ParsedEnum;
but that gives:
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
any ideas on this sort of functionality?
The text was updated successfully, but these errors were encountered:
EnumeratedValueArgument is not the best here. It is meant for cases where you have a known set of primitive values you want to allow. E.g. 1,2,3,4,5,6
You can use plain ValueArgument:
ValueArgument<MyEnum> //(in code)
or
[ValueArgument(typeof(MyEnum),...)] //(in attributes)
it should work fine for you
Sorry, something went wrong.
Darn, guess no method for grabbing the list of valid values from the enum using that attribute either eh?
No branches or pull requests
At a glance, I'm not seeing a method of using an
enum
along withEnumeratedValueArgument
, specifically when using a attribute style parsing target.I was hoping for something like:
or perhaps:
but that gives:
any ideas on this sort of functionality?
The text was updated successfully, but these errors were encountered: