public static void SerializeXML(CommissionAccount account) { if (account == null) { throw new ArgumentNullException(nameof(account), ExceptionMessages.CASerializerNullAccount()); } SerializeXML(account, account.AccountID + ".xml"); }
public static void SerializeXML(CommissionAccount account, string filePath) { if (account == null) { throw new ArgumentNullException(nameof(account), ExceptionMessages.CASerializerNullAccount()); } XmlSerializer xmlSerializer = new XmlSerializer(typeof(CommissionAccount)); using (FileStream stream = File.Create(filePath)) { xmlSerializer.Serialize(stream, account); } }
public static void SerializeBinary(CommissionAccount account) { if (account == null) { throw new ArgumentNullException(nameof(account), ExceptionMessages.CASerializerNullAccount()); } BinaryFormatter bFormatter = new BinaryFormatter(); using (FileStream stream = File.Create(account + ".txt")) { bFormatter.Serialize(stream, account); } }