mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-21 10:01:58 +01:00
- Remove CommonServiceLocator - Remove GalaSoft.MvvmLight - Add CommunityToolkit.Mvvm
29 lines
1.0 KiB
C#
29 lines
1.0 KiB
C#
// <copyright file="XmlHelpers.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
|
|
|
namespace FileConverter
|
|
{
|
|
public class XmlHelpers
|
|
{
|
|
public static void LoadFromFile<T>(string root, string path, out T deserializedObject)
|
|
{
|
|
FileConverterExtension.XmlHelpers.LoadFromFile(root, path, out deserializedObject);
|
|
|
|
if (deserializedObject is IXmlSerializable xmlSerializableObject)
|
|
{
|
|
xmlSerializableObject.OnDeserializationComplete();
|
|
}
|
|
}
|
|
|
|
public static void SaveToFile<T>(string root, string path, T objectToSerialize)
|
|
{
|
|
try
|
|
{
|
|
FileConverterExtension.XmlHelpers.SaveToFile(root, path, objectToSerialize);
|
|
}
|
|
catch (System.Exception exception)
|
|
{
|
|
Diagnostics.Debug.LogError("Fail to save asset of type '" + typeof(T) + "'. The following exception was raised:\n " + exception.Message);
|
|
}
|
|
}
|
|
}
|
|
} |