Aetheria/Assets/Plugins/MSAGL/DebugHelpers/CurveSerializer.cs
Reinier Vens dbc522a224 Weapos Rejiggered
Modified weapon scripts to eliminate specialized projectile behavior - allows charged weapons to have projectiles and modify weapon stats when charged
Added machine gun weapon & VFX
Moved third party code to Plugins folder to improve compile times
2021-01-31 03:52:32 +00:00

52 lines
No EOL
1.4 KiB
C#

using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
#if DEBUGGLEE
namespace Microsoft.Msagl.Splines {
/// <summary>
/// For debugging purposees only
/// </summary>
internal class CurveSerializer {
CurveSerializer() { }
internal static void Serialize(string fileName, ICurve i) {
Stream file = File.Open(fileName, FileMode.Create);
// Create a formatter object based on command line arguments
IFormatter formatter = new BinaryFormatter();
// Serialize the object graph to stream
formatter.Serialize(file, i);
// All done
file.Close();
}
internal static ICurve Deserialize(string fileName) {
// Verify that the input file exists
if (!File.Exists(fileName))
return null;
// Open the requested file to a stream object
Console.WriteLine("\nDeserializing LinkedList from file: {0} ..\n", fileName);
Stream file = File.Open(fileName, FileMode.Open);
IFormatter formatter = new BinaryFormatter();
try {
ICurve i = formatter.Deserialize(file) as ICurve;
return i;
} catch (Exception) {
throw;
} finally {
file.Close();
}
}
}
}
#endif