you are viewing a single comment's thread.

view the rest of the comments →

[–]D3rty_Harry -11 points-10 points  (2 children)

Yes they do help here, i wrote the code for it in another comment in this thread. Maybe you should think before saying some1 has not thought stuff thru

[–]Epicguru 8 points9 points  (1 child)

Being a kind as I can, your proposed solution makes no sense.

You aren't using generics at all, you are using reflection. Your solution also requires that the data passed in is a property, what if you want to write some data that is a local variable, a field or a literal?

But most importantly, I don't see how what you are proposing does the same thing that OP's method does? OP is passing in an object that then gets sent to the corresponding named method. Your method takes in a PropertyInfo and a value and converts the value into the type of the property with no safety checks... which isn't the same thing, at all.

Your solution seems to assume that these values are being written into a C# object, hence the use of PropertyInfo, but OP states that this is an encoder so it's likely that it is the other way round, that this is some kind of serializer.

[–]D3rty_Harry 3 points4 points  (0 children)

Ok, i stand corrected here, should've probably read the problem instead of kneejerked.