diff --git a/Lib.Driver/DriverLoader.cs b/Lib.Driver/DriverLoader.cs new file mode 100644 index 0000000..c4c8928 --- /dev/null +++ b/Lib.Driver/DriverLoader.cs @@ -0,0 +1,23 @@ +// Author: Gockner, Simon +// Created: 2021-04-09 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using System.IO; +using System.Xml; +using System.Xml.Serialization; +using Lib.Driver.Interfaces; +using Lib.Driver.Xml; + +namespace Lib.Driver +{ + public class DriverLoader : IDriverLoader + { + public XmlDriver Load(string driverPath) + { + XmlReader xmlReader = XmlReader.Create(File.OpenRead(driverPath)); + XmlSerializer xmlSerializer = new(typeof(XmlDriver)); + + return (XmlDriver) xmlSerializer.Deserialize(xmlReader); + } + } +} \ No newline at end of file diff --git a/Lib.Driver/Factories/IDriverLoaderFactory.cs b/Lib.Driver/Factories/IDriverLoaderFactory.cs new file mode 100644 index 0000000..45d5538 --- /dev/null +++ b/Lib.Driver/Factories/IDriverLoaderFactory.cs @@ -0,0 +1,13 @@ +// Author: Gockner, Simon +// Created: 2021-04-09 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using Lib.Driver.Interfaces; + +namespace Lib.Driver.Factories +{ + public interface IDriverLoaderFactory + { + IDriverLoader Create(); + } +} \ No newline at end of file diff --git a/Lib.Driver/Interfaces/IDriverLoader.cs b/Lib.Driver/Interfaces/IDriverLoader.cs new file mode 100644 index 0000000..ea4b1ea --- /dev/null +++ b/Lib.Driver/Interfaces/IDriverLoader.cs @@ -0,0 +1,13 @@ +// Author: Gockner, Simon +// Created: 2021-04-09 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using Lib.Driver.Xml; + +namespace Lib.Driver.Interfaces +{ + public interface IDriverLoader + { + XmlDriver Load(string driverPath); + } +} \ No newline at end of file diff --git a/Lib.Driver/Lib.Driver.csproj b/Lib.Driver/Lib.Driver.csproj new file mode 100644 index 0000000..cbfa581 --- /dev/null +++ b/Lib.Driver/Lib.Driver.csproj @@ -0,0 +1,7 @@ + + + + net5.0 + + + diff --git a/Lib.Driver/Xml/XmlButton.cs b/Lib.Driver/Xml/XmlButton.cs new file mode 100644 index 0000000..85035b1 --- /dev/null +++ b/Lib.Driver/Xml/XmlButton.cs @@ -0,0 +1,15 @@ +// Author: Gockner, Simon +// Created: 2021-04-09 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using System.Xml.Serialization; + +namespace Lib.Driver.Xml +{ + [XmlRoot("Button")] + public class XmlButton + { + [XmlElement("Type")] + public string ButtonType { get; set; } + } +} \ No newline at end of file diff --git a/Lib.Driver/Xml/XmlChannel.cs b/Lib.Driver/Xml/XmlChannel.cs new file mode 100644 index 0000000..bec90b1 --- /dev/null +++ b/Lib.Driver/Xml/XmlChannel.cs @@ -0,0 +1,23 @@ +// Author: Gockner, Simon +// Created: 2021-04-09 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace Lib.Driver.Xml +{ + [XmlRoot("Channel")] + public class XmlChannel + { + [XmlElement("Fader")] + public XmlFader Fader { get; set; } + + [XmlElement("Knob")] + public XmlKnob Knob { get; set; } + + [XmlArray("Buttons")] + [XmlArrayItem("Button", typeof(XmlButton))] + public List Buttons { get; set; } + } +} \ No newline at end of file diff --git a/Lib.Driver/Xml/XmlDriver.cs b/Lib.Driver/Xml/XmlDriver.cs new file mode 100644 index 0000000..4408e87 --- /dev/null +++ b/Lib.Driver/Xml/XmlDriver.cs @@ -0,0 +1,17 @@ +// Author: Gockner, Simon +// Created: 2021-04-09 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace Lib.Driver.Xml +{ + [XmlRoot("MidiDevice")] + public class XmlDriver + { + [XmlArray("Channels")] + [XmlArrayItem("Channel", typeof(XmlChannel))] + public List Channels { get; set; } + } +} \ No newline at end of file diff --git a/Lib.Driver/Xml/XmlFader.cs b/Lib.Driver/Xml/XmlFader.cs new file mode 100644 index 0000000..12aeaf4 --- /dev/null +++ b/Lib.Driver/Xml/XmlFader.cs @@ -0,0 +1,14 @@ +// Author: Gockner, Simon +// Created: 2021-04-09 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using System.Xml.Serialization; + +namespace Lib.Driver.Xml +{ + [XmlRoot("Fader")] + public class XmlFader + { + + } +} \ No newline at end of file diff --git a/Lib.Driver/Xml/XmlKnob.cs b/Lib.Driver/Xml/XmlKnob.cs new file mode 100644 index 0000000..13ab78b --- /dev/null +++ b/Lib.Driver/Xml/XmlKnob.cs @@ -0,0 +1,14 @@ +// Author: Gockner, Simon +// Created: 2021-04-09 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using System.Xml.Serialization; + +namespace Lib.Driver.Xml +{ + [XmlRoot("Knob")] + public class XmlKnob + { + + } +} \ No newline at end of file diff --git a/Mystify.sln b/Mystify.sln index b70d36e..08818f6 100644 --- a/Mystify.sln +++ b/Mystify.sln @@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib.Audio", "Lib.Audio\Lib. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib.Midi", "Lib.Midi\Lib.Midi.csproj", "{E4359142-6D64-4103-ADDF-7AD6A5663F17}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib.Driver", "Lib.Driver\Lib.Driver.csproj", "{3C246E60-EC2B-41FE-AB1C-96B8C4FD9136}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,5 +32,9 @@ Global {E4359142-6D64-4103-ADDF-7AD6A5663F17}.Debug|Any CPU.Build.0 = Debug|Any CPU {E4359142-6D64-4103-ADDF-7AD6A5663F17}.Release|Any CPU.ActiveCfg = Release|Any CPU {E4359142-6D64-4103-ADDF-7AD6A5663F17}.Release|Any CPU.Build.0 = Release|Any CPU + {3C246E60-EC2B-41FE-AB1C-96B8C4FD9136}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C246E60-EC2B-41FE-AB1C-96B8C4FD9136}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C246E60-EC2B-41FE-AB1C-96B8C4FD9136}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C246E60-EC2B-41FE-AB1C-96B8C4FD9136}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal