/Repository/StitchOptions.cs |
@@ -0,0 +1,82 @@ |
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // |
// Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
// rights of fair usage, the disclaimer and warranty conditions. // |
/////////////////////////////////////////////////////////////////////////// |
|
using System.Collections.Generic; |
using System.IO; |
using System.Xml.Serialization; |
using wasSharp; |
|
namespace wasStitchNET.Repository |
{ |
[XmlRoot(ElementName = "FileExcludes")] |
public class FileExcludes |
{ |
[XmlElement(ElementName = "Path")] |
public HashSet<string> Path { get; set; } |
} |
|
[XmlRoot(ElementName = "ConfigurationExcludes")] |
public class ConfigurationExcludes |
{ |
[XmlElement(ElementName = "Path")] |
public HashSet<string> Tag { get; set; } |
} |
|
[XmlRoot(ElementName = "ConfigurationForce")] |
public class ConfigurationForce |
{ |
[XmlElement(ElementName = "Path")] |
public HashSet<string> Tag { get; set; } |
} |
|
[XmlRoot(ElementName = "StitchOptions")] |
public class StitchOptions |
{ |
[Reflection.NameAttribute("force")] |
[XmlElement(ElementName = "force")] |
public bool Force { get; set; } |
|
[Reflection.NameAttribute("FileExcludes")] |
[XmlElement(ElementName = "FileExcludes")] |
public FileExcludes FileExcludes { get; set; } |
|
[Reflection.NameAttribute("ConfigurationExcludes")] |
[XmlElement(ElementName = "ConfigurationExcludes")] |
public ConfigurationExcludes ConfigurationExcludes { get; set; } |
|
[Reflection.NameAttribute("ConfigurationForce")] |
[XmlElement(ElementName = "ConfigurationForce")] |
public ConfigurationExcludes ConfigurationForce { get; set; } |
|
[XmlAttribute(AttributeName = "xsi", Namespace = "http://www.w3.org/2000/xmlns/")] |
public string Xsi { get; set; } |
|
[XmlAttribute(AttributeName = "xsd", Namespace = "http://www.w3.org/2000/xmlns/")] |
public string Xsd { get; set; } |
} |
|
public static class StitchOptionsSerialization |
{ |
public static StitchOptions Load(this StitchOptions stitchOptions, Stream stream) |
{ |
using (var streamReader = new StreamReader(stream)) |
{ |
var serializer = new XmlSerializer(typeof(StitchOptions)); |
return (StitchOptions) serializer.Deserialize(streamReader); |
} |
} |
|
public static string ToXML(this StitchOptions stitchOptions) |
{ |
using (var writer = new StringWriter()) |
{ |
var serializer = new XmlSerializer(typeof(StitchOptions)); |
serializer.Serialize(writer, stitchOptions); |
return writer.ToString(); |
} |
} |
} |
} |