Note that there are some explanatory texts on larger screens.

plurals
  1. POCan protobuf-net serialize this combination of interface and generic collection?
    text
    copied!<p>I am trying to serialize a <code>ItemTransaction</code> and protobuf-net (r282) is having a problem. </p> <pre><code>ItemTransaction : IEnumerable&lt;KeyValuePair&lt;Type, IItemCollection&gt;&gt;&lt;/code&gt; </code></pre> <p>and ItemCollection is like this:</p> <pre><code>FooCollection : ItemCollection&lt;Foo&gt; ItemCollection&lt;T&gt; : BindingList&lt;T&gt;, IItemCollection IItemCollection : IList&lt;Item&gt; </code></pre> <p>where T is a derived type of Item. ItemCollection also has a property of type IItemCollection.</p> <p>I am serializing like this:</p> <pre><code>IItemCollection itemCol = someService.Blah(...); ... SerializeWithLengthPrefix&lt;IItemCollection&gt;(stream, itemCol, PrefixStyle.Base128); </code></pre> <p>My eventual goal is to serialize ItemTransaction, but am snagged with IItemCollection. </p> <p>Item and it's derived types can be [de]serialized with no issues, see [1], but deserializing an IItemCollection fails (serializing works). ItemCollection has a ItemExpression property and when deserializing protobuf can't create an abstract class. This makes sense to me, but I'm not sure how to get through it.</p> <pre><code>ItemExpression&lt;T&gt; : ItemExpression, IItemExpression ItemExpression : Expression </code></pre> <p>ItemExpression is abstract as is Expression</p> <p>How do I get this to work properly?</p> <p>Also, I am concerned that ItemTransaction will fail since the IItemCollections are going to be differing and unknown at compile time (an ItemTransaction will have FooCollection, BarCollection, FlimCollection, FlamCollection, etc). </p> <p>What am I missing (Marc) ?</p> <p>[1] <a href="https://stackoverflow.com/questions/2276104/protobuf-net-deserializing-across-assembly-boundaries">protobuf-net [de]serializing across assembly boundaries</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload