I see the SetFactory method on Protobuf-net. However, it appears to be available on per type basis. (And MethodInfo or a string? Can I hear it for Func<T>
?)
What I want is the ability to use my IoC container's object resolution and construction abilities for all deserialization. (I'm using Autofac.) Protobuf-net should first attempt to use my IoC on any construction. If that returns null then I want the default behavior. Is there some way to do this currently? Thanks for your time.
Not currently. The reason it doesn't take a delegate is that it aims to static-compile the model - MethodInfo is fine for that, but delegates: not so much. The factory method you supply, however, can take the serialization context which can contain whatever objects you need.
I could think about a default factory method - that sounds possible; I'll need to let one of the args be a Type, but that isn't a problem.
Would the ability to set "a default factory MethodInfo that can take (if it wants) a Type and a serialization-context" suffice?
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