Hello,
I am trying to use the Persistence Framework to persist a custom object, and am hoping to confirm some of the behaviour that I am seeing.
If I do not specify a custom property provider for my type, I observe the following:
I am trying to use the Persistence Framework to persist a custom object, and am hoping to confirm some of the behaviour that I am seeing.
If I do not specify a custom property provider for my type, I observe the following:
- Only properties that are primitive types get persisted.
- However, nullable types are not supported. You cannot return null for ProvideValue.
- Properties that are complex types (i.e. other classes) do not get persisted.
- Implementing ISerializable my classes (top-level or property classes) makes no difference! (I.e. ISerializable.GetObjectData never gets called.)
If I do specify a custom property provider, I observe the following:
- Only properties returned in GetCustomProperties get persisted. This means, that I need to specify (and support) every property that I want persisted - even ones of primitive types.
- For complex properties, I can create proxy objects to be saved. But if these property types themselves have complex properties, it seems I need to package up the entire property tree in the proxy for my top-level property. Is this true??!
- Again, implementing ISerializable makes no difference as it never gets called. This would be a nice way to serialize deep property structures as described in the previous point.
Since the persistence framework has a method that returns a Stream for a particular object, it surprises me that implementing ISerializable on the object I wish to persist does not help. Am I missing something?
Finally, if you cannot implement ISerializable, how do you go about persisting deep structures using the custom property provider?
If someone could help clarify these observations, and perhaps offer a suggeestion about these deep property structures, that would be great!!
Thanks,
Mark