Created
November 8, 2023 19:57
-
-
Save ahmetkucukoglu/367ab304656d396823aefb8e1397d6d1 to your computer and use it in GitHub Desktop.
XmlProductsExporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class XmlProductsExporter : IProductsExporter | |
{ | |
public string Export(List<Product> products) | |
{ | |
var xmlSerializer = new XmlSerializer(products.GetType()); | |
using var stringWriter = new StringWriter(); | |
using var xmlWriter = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented }; | |
xmlSerializer.Serialize(xmlWriter, products); | |
return stringWriter.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment