public void SerializationBinary() { CurveKey2F curveKey1 = new CurveKey2F { Interpolation = SplineInterpolation.Bezier, Point = new Vector2F(1.2f, 3.4f), TangentIn = new Vector2F(0.7f, 2.6f), TangentOut = new Vector2F(1.9f, 3.3f) }; CurveKey2F curveKey2; const string fileName = "SerializationCurve2FKey.bin"; if (File.Exists(fileName)) { File.Delete(fileName); } FileStream fs = new FileStream(fileName, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(fs, curveKey1); fs.Close(); fs = new FileStream(fileName, FileMode.Open); formatter = new BinaryFormatter(); curveKey2 = (CurveKey2F)formatter.Deserialize(fs); fs.Close(); MathAssert.AreEqual(curveKey1, curveKey2); }
public void SerializationBinary() { PathKey3F pathKey1 = new PathKey3F { Interpolation = SplineInterpolation.Bezier, Parameter = 56.7f, Point = new Vector3F(1.2f, 3.4f, 5.6f), TangentIn = new Vector3F(0.7f, 2.6f, 5.1f), TangentOut = new Vector3F(1.9f, 3.3f, 5.9f) }; PathKey3F pathKey2; const string fileName = "SerializationPath3FKey.bin"; if (File.Exists(fileName)) { File.Delete(fileName); } FileStream fs = new FileStream(fileName, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(fs, pathKey1); fs.Close(); fs = new FileStream(fileName, FileMode.Open); formatter = new BinaryFormatter(); pathKey2 = (PathKey3F)formatter.Deserialize(fs); fs.Close(); MathAssert.AreEqual(pathKey1, pathKey2); }
public void SerializationXml() { CurveKey2F curveKey1 = new CurveKey2F { Interpolation = SplineInterpolation.Bezier, Point = new Vector2F(1.2f, 3.4f), TangentIn = new Vector2F(0.7f, 2.6f), TangentOut = new Vector2F(1.9f, 3.3f) }; CurveKey2F curveKey2; const string fileName = "SerializationCurve2FKey.xml"; if (File.Exists(fileName)) { File.Delete(fileName); } XmlSerializer serializer = new XmlSerializer(typeof(CurveKey2F)); StreamWriter writer = new StreamWriter(fileName); serializer.Serialize(writer, curveKey1); writer.Close(); serializer = new XmlSerializer(typeof(CurveKey2F)); FileStream fileStream = new FileStream(fileName, FileMode.Open); curveKey2 = (CurveKey2F)serializer.Deserialize(fileStream); MathAssert.AreEqual(curveKey1, curveKey2); }
public void SerializationXml() { PathKey3F pathKey1 = new PathKey3F { Interpolation = SplineInterpolation.Bezier, Parameter = 56.7f, Point = new Vector3F(1.2f, 3.4f, 5.6f), TangentIn = new Vector3F(0.7f, 2.6f, 5.1f), TangentOut = new Vector3F(1.9f, 3.3f, 5.9f) }; PathKey3F pathKey2; const string fileName = "SerializationPath3FKey.xml"; if (File.Exists(fileName)) { File.Delete(fileName); } XmlSerializer serializer = new XmlSerializer(typeof(PathKey3F)); StreamWriter writer = new StreamWriter(fileName); serializer.Serialize(writer, pathKey1); writer.Close(); serializer = new XmlSerializer(typeof(PathKey3F)); FileStream fileStream = new FileStream(fileName, FileMode.Open); pathKey2 = (PathKey3F)serializer.Deserialize(fileStream); MathAssert.AreEqual(pathKey1, pathKey2); }