static void Main(string[] args) { Car car = new Car(); car.Name = "Epa"; CarTools.SaveCarZip("test.zip", car); Car newCar = CarTools.LoadCarZip("test.zip"); Console.WriteLine("Name: {0}", newCar.Name); Console.ReadLine(); }
public CarController() { physics = new Car(); speed = rotation = 0f; position = new Vector2(500f, 50f); wheel1pos = new Vector2(0f, 0f); wheel2pos = new Vector2(0f, 0f); wheel1offset = new Vector2(60f, 17.0f); wheel2offset = new Vector2(-60f, 17.0f); wheelRotation = 0f; spring1 = spring2 = 0f; }
public static void SaveCarXml(Stream stream, Car carToSave) { DataContractSerializer ser = new DataContractSerializer(typeof(Car)); ser.WriteObject(stream, carToSave); }
public static void SaveCarZip(string filename,Car carToSave) { Stream fileStream = File.Open(filename, FileMode.Create); GZipStream zipStream = new GZipStream(fileStream, CompressionMode.Compress); SaveCarXml(zipStream, carToSave); zipStream.Close(); fileStream.Close(); }
public static void SaveCarXml(string filename, Car carToSave) { Stream stream = File.Open(filename, FileMode.Append); DataContractSerializer ser = new DataContractSerializer(typeof(Car)); ser.WriteObject(stream, carToSave); stream.Close(); }