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,object> {...} )]
atm I'm thinking to just pass a json string and after transform it into IDictionary<string,object>
“ kwargs ” stands for keyword arguments. It is used for passing advanced data objects like dictionaries to a function because in such functions one doesn't have a clue about the number of arguments, hence data passed is be dealt properly by adding “**” to the passing type.
In essence, one can say that mutable objects like dictionaries, sets, and lists are passed by reference. Immutable objects like int , str , tuple are passed by value.
Python's argument passing model is neither “Pass by Value” nor “Pass by Reference” but it is “Pass by Object Reference”.
We can pass a dictionary to a function by passing the name of the dictionary. Let's define a function that accepts a dictionary as a parameter.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With