Skip to content

Instantly share code, notes, and snippets.

@ahmetkucukoglu
Created November 8, 2023 19:57
Show Gist options
  • Save ahmetkucukoglu/367ab304656d396823aefb8e1397d6d1 to your computer and use it in GitHub Desktop.
Save ahmetkucukoglu/367ab304656d396823aefb8e1397d6d1 to your computer and use it in GitHub Desktop.
XmlProductsExporter
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