question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to call the IExtendedXmlSerializer from IExtendedXmlCustomSerializer?

See original GitHub issue

Hello 😉

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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
manureinicommented, Aug 18, 2018

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.

0reactions
Mike-E-angelocommented, Aug 19, 2018

Boh! Good point. Fixed. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extended XML Serializer for .NET
Serialization circular reference and reference Id; Deserialization of old version of xml; Property encryption; Custom serializer; Support ...
Read more >
ExtendedXmlSerializer/home: A configurable and ...
Specializes in POCO-based object graph serialization; Features a powerful extension model; Operates in the tried-and-trusted dependable XML format.. "But ...
Read more >
ACS-Solutions/ExtendedXmlSerializer
If you want create custom serializer, your class must inherit from IXmlSerializable. This means that your class will not be a POCO class....
Read more >
c# - Custom Serialization using XmlSerializer
I have a class that I need to do some custom XML output from, thus I implement the IXmlSerializable interface. However, some of...
Read more >
Welcome to ExtendedXmlSerializer's documentation ...
ExtendedXmlSerializer for .NET ... Custom serialization · Deserialize old version of xml · Extensibility · Object reference and circular reference ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found