using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace CreateUpdateXmlFile
{
  public class ClientVersion
  {
    public string Version { get; set; }

    public string ServerUrl { get; set; }

    private List<UpdateFile> _update = new List<UpdateFile>();
    public List<UpdateFile> UpdateFiles { get { return _update; } set { _update = value; } }
  }

  public class UpdateFile
  {
    public string FileName { get; set; }

    public string Url { get; set; }

    public int Size { get; set; }

    public bool NeedRestart { get; set; }
  }

  public static class XmlUtil
  {
    public static void SerializerObjToFile(object obj, string fileName = "")
    {
      if (string.IsNullOrWhiteSpace(fileName))
      {
        fileName = obj.GetType().Name + ".xml";
      }
      var ser = new XmlSerializer(obj.GetType());
      using (var stream = File.Open(fileName, FileMode.Create))
      {
        ser.Serialize(stream, obj);
      }
    }
  }
}
