mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 07:30:40 +01:00
Removed duplicate methods
This commit is contained in:
parent
990c745d6d
commit
267e6dd0ca
1 changed files with 12 additions and 12 deletions
|
|
@ -11,6 +11,7 @@ namespace SceneManager.Utils
|
||||||
internal static class Serializer
|
internal static class Serializer
|
||||||
{
|
{
|
||||||
private static Dictionary<Type, XmlSerializer> _serializerCache = new Dictionary<Type, XmlSerializer>();
|
private static Dictionary<Type, XmlSerializer> _serializerCache = new Dictionary<Type, XmlSerializer>();
|
||||||
|
|
||||||
private static XmlSerializer _getOrCreateSerializer<T>(XmlAttributeOverrides overrides = null)
|
private static XmlSerializer _getOrCreateSerializer<T>(XmlAttributeOverrides overrides = null)
|
||||||
{
|
{
|
||||||
if (_serializerCache.ContainsKey(typeof(T)))
|
if (_serializerCache.ContainsKey(typeof(T)))
|
||||||
|
|
@ -74,7 +75,7 @@ namespace SceneManager.Utils
|
||||||
SaveItemToXML(list, filePath);
|
SaveItemToXML(list, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SaveItemToXML<T>(T item, string path, XmlAttributeOverrides overrides)
|
public static void SaveItemToXML<T>(T item, string path, XmlAttributeOverrides overrides = null)
|
||||||
{
|
{
|
||||||
Encoding utf8NoBom = new UTF8Encoding(false);
|
Encoding utf8NoBom = new UTF8Encoding(false);
|
||||||
using (TextWriter writer = new StreamWriter(path, false, utf8NoBom))
|
using (TextWriter writer = new StreamWriter(path, false, utf8NoBom))
|
||||||
|
|
@ -82,17 +83,16 @@ namespace SceneManager.Utils
|
||||||
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
||||||
ns.Add("", "");
|
ns.Add("", "");
|
||||||
|
|
||||||
//new XmlSerializer(typeof(Objects.Path)).Serialize(writer, item);
|
_getOrCreateSerializer<T>(overrides).Serialize(writer, item, ns);
|
||||||
_getOrCreateSerializer<Paths.Path>(overrides).Serialize(writer, item, ns);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SaveItemToXML<T>(T item, string path)
|
//public static void SaveItemToXML<T>(T item, string path)
|
||||||
{
|
//{
|
||||||
SaveItemToXML<T>(item, path, null);
|
// SaveItemToXML(item, path, null);
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static T LoadItemFromXML<T>(string filePath, XmlAttributeOverrides overrides)
|
public static T LoadItemFromXML<T>(string filePath, XmlAttributeOverrides overrides = null)
|
||||||
{
|
{
|
||||||
if (!File.Exists(filePath)) throw new FileNotFoundException($"{nameof(LoadItemFromXML)}(): specified file does not exist: {filePath}");
|
if (!File.Exists(filePath)) throw new FileNotFoundException($"{nameof(LoadItemFromXML)}(): specified file does not exist: {filePath}");
|
||||||
|
|
||||||
|
|
@ -102,10 +102,10 @@ namespace SceneManager.Utils
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T LoadItemFromXML<T>(string filePath)
|
//public static T LoadItemFromXML<T>(string filePath)
|
||||||
{
|
//{
|
||||||
return LoadItemFromXML<T>(filePath, null);
|
// return LoadItemFromXML<T>(filePath, null);
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static void ModifyItemInXML<T>(string filePath, Action<T> modification)
|
public static void ModifyItemInXML<T>(string filePath, Action<T> modification)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue