pass IDictionary<,> as a parameter in attribute, possible?
is it possible to pass an IDictionary as an attribute's parameter: like this:
[My(new Dictionary<string,object> { ... }]
or like this:
[My(Data = new Dictionary<string,obje开发者_JS百科ct> {...} )]
atm I'm thinking to just pass a json string and after transform it into IDictionary<string,object>
No - with attributes you have to pass constant values to them. Perhaps you could have multiple attributes with two properties exposed.
[My(Key = "1234", Value = "1234")]
[My(Key = "4234", Value = "4234")]
When you do your reflection, you could build a dictionary that way.
No, you'll get this error:
Error 20
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
精彩评论