/// <summary> /// Writes the given object instance to a binary file. /// <para>Object type (and all child types) must be decorated with the [Serializable] attribute.</para> /// <para>To prevent a variable from being serialized, decorate it with the [NonSerialized] attribute; cannot be applied to properties.</para> /// </summary> /// <typeparam name="T">The type of object being written to the binary file.</typeparam> /// <param name="filePath">The file path to write the object instance to.</param> /// <param name="objectToWrite">The object instance to write to the binary file.</param> /// <param name="append">If false the file will be overwritten if it already exists. If true the contents will be appended to the file.</param> public static void WriteToBinaryFile(string filePath, BulkFile bulkFile, bool append = false) { using (Stream stream = File.Open(filePath, append ? FileMode.Append : FileMode.Create)) { var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(stream, bulkFile); } }
public NewRecordSimulation(BulkFile bulkFile, Person newPerson) { BulkFile = bulkFile; NewPerson = newPerson; KeyTransformation = -1; OverrunZone = false; Column = -1; }
public DeleteRecordSimulation(BulkFile bulkFile, int id, bool logical) { BulkFile = bulkFile; Id = id; Logical = logical; KeyTransformation = -1; OverrunZone = false; KeyTransformation = -1; Column = -1; }
public EditRecordSimulation(BulkFile bulkFile, int id, string newFullName, string newAddress, int?newAge) { BulkFile = bulkFile; Id = id; NewFullName = newFullName; NewAddress = newAddress; NewAge = newAge; OverrunZone = false; Row = -1; Column = -1; }