You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
917 B
32 lines
917 B
// Author: Gockner, Simon
|
|
// Created: 2021-04-27
|
|
// Copyright(c) 2021 SimonG. All Rights Reserved.
|
|
|
|
using System.IO;
|
|
using System.Xml;
|
|
using System.Xml.Serialization;
|
|
using Lib.Xml.Interfaces;
|
|
|
|
namespace Lib.Xml
|
|
{
|
|
public class XmlWriter<T> : XmlWriter<T, T>, IXmlWriter<T>
|
|
{
|
|
|
|
}
|
|
|
|
public class XmlWriter<TData, TXml> : IXmlWriter<TData, TXml> where TXml : TData
|
|
{
|
|
public void Write(TData data, string filePath)
|
|
{
|
|
FileStream file = File.OpenWrite(filePath);
|
|
|
|
XmlWriter xmlWriter = XmlWriter.Create(file, new XmlWriterSettings {Indent = true});
|
|
XmlSerializer xmlSerializer = new(typeof(TXml));
|
|
|
|
XmlSerializerNamespaces xmlSerializerNamespaces = new();
|
|
xmlSerializerNamespaces.Add("", "");
|
|
|
|
xmlSerializer.Serialize(xmlWriter, data, xmlSerializerNamespaces);
|
|
}
|
|
}
|
|
} |