The problem: You've got your TrimRequest, and you're trying to populate the items. Unfortunately, the number of Operations in TrimRequest.Items is going to change dynamically, and there isn't any .Add method.
The solution: Create an ArrayList, and stick all your Operations in there. 'Cause their cool, ArrayLists do have a .Add method (and a .AddRange). Once you're finished with it, jam it into the TrimRequest.Items.
The trick is that the cast isn't good, so the code won't complie.
Thanks to the awesomness of Resharper, I discovered that if you hack the generated code and change the line
public Operation[] Items;to
public object[] Items;That will let you pass all the operations into the collection, and through the joys of XML, it will magically work at the other end.
I need to do some further testing on this, but it looks good for the moment.
There is also a ToArray() method on the ArrayList which will do the right thing.
ReplyDeleteMikal
No, I was using .ToArray() to pass it back into the req.Items. That was where the cast was failing.
ReplyDeleteI think it has trouble realising that the objects in the ArrayList are actually operations.