diff --git a/RGB.NET.Layout/DeviceLayout.cs b/RGB.NET.Layout/DeviceLayout.cs
index bdddb99..24efd37 100644
--- a/RGB.NET.Layout/DeviceLayout.cs
+++ b/RGB.NET.Layout/DeviceLayout.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
@@ -118,20 +118,16 @@ public class DeviceLayout : IDeviceLayout
///
/// Creates a new from the specified xml.
///
- /// The path to the xml file.
+ /// The stream that contains the layout to be loaded.
/// The type of the custom data.
/// The type of the custom data of the leds.
/// The deserialized .
- public static DeviceLayout? Load(string path, Type? customDeviceDataType = null, Type? customLedDataType = null)
+ public static DeviceLayout? Load(Stream stream, Type? customDeviceDataType = null, Type? customLedDataType = null)
{
- if (!File.Exists(path)) return null;
-
try
{
XmlSerializer serializer = new(typeof(DeviceLayout));
- using StreamReader reader = new(path);
-
- DeviceLayout? layout = serializer.Deserialize(reader) as DeviceLayout;
+ DeviceLayout? layout = serializer.Deserialize(stream) as DeviceLayout;
if (layout != null)
layout.CustomData = layout.GetCustomData(layout.InternalCustomData, customDeviceDataType);
@@ -155,6 +151,21 @@ public class DeviceLayout : IDeviceLayout
}
}
+ ///
+ /// Creates a new from the specified xml.
+ ///
+ /// The path to the xml file.
+ /// The type of the custom data.
+ /// The type of the custom data of the leds.
+ /// The deserialized .
+ public static DeviceLayout? Load(string path, Type? customDeviceDataType = null, Type? customLedDataType = null)
+ {
+ if (!File.Exists(path)) return null;
+
+ using Stream stream = File.OpenRead(path);
+ return Load(stream, customDeviceDataType, customLedDataType);
+ }
+
///
/// Gets the deserialized custom data.
///
@@ -177,4 +188,4 @@ public class DeviceLayout : IDeviceLayout
}
#endregion
-}
\ No newline at end of file
+}