How to call the IExtendedXmlSerializer from IExtendedXmlCustomSerializer?
See original GitHub issueHello 😉
Thanks for your great library. I just found it and started to implement an ExtendedXmlCustomSerializer. I want to serialize a property with the default IExtendedXmlSerializer class. Something like a recursive call.
I read Issue #154. And tried this code:
https://github.com/wojtpl2/ExtendedXmlSerializer/blob/master/test/ExtendedXmlSerializer.Tests/ReportedIssues/Issue154Tests.cs#L174-L186
But the _serializers
contains only the custom serializers.
I’m looking for something like this:
public class RandomTypeSerializer : IExtendedXmlCustomSerializer<RandomType> {
public void Serializer(XmlWriter writer, RandomType obj) {
xmlWriter.WriteAttributeString("Description", obj.Description);
// Serializer.Serialize("IRandomType2", obj.RandomType2);
}
[...]
}
Does the current version supports this? If yes, how to implement it?
My main goal is to serialize an open generic type. This is why my idea is to create an IExtendedXmlCustomSerializer which will store the Typename as string and recreate the generic class. One property of this generic class is an interface which can have different types and circular references.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Hello 😉
Wow! Thank you very much. There is no delay, when you answer so fast 😉
I was able to get the Serializer running 😉 Thanks for your example.
The only thing I changed: https://github.com/wojtpl2/ExtendedXmlSerializer/blob/14ed5908649abdf0ab09332324a9b67c7da40c5b/test/ExtendedXmlSerializer.Tests/ReportedIssues/Issue193Tests.cs#L77 to
var result = typeof(RandomType).IsAssignableFrom(parameter) ? new Serializer(serializer).Adapt() : serializer;
because if RandomType is an interface it did not work for me 😉
Thank you very much for your support!
I don’t know how v3 looks like. But I’m already happy with v2.
Boh! Good point. Fixed. 😄