/// <summary> /// Saves history. /// </summary> private void SaveHistory() { // adapter of list view ArrayAdapter <Utils.BarcodeInformation> adapter = _barcodeGeneratorFragment.ListAdapter as ArrayAdapter <Utils.BarcodeInformation>; if (adapter != null) { try { // open file stream to save history using (FileStream fileStream = new FileStream(_historyFilePath, FileMode.Create, FileAccess.Write)) { // open java object stream, which allows to seralize objects to a file using (Java.IO.ObjectOutputStream outStream = new Java.IO.ObjectOutputStream(fileStream)) { // temp list to get serialized items List <ArrayList> list = new List <ArrayList>(); // for each list item for (int index = 0; index < adapter.Count; index++) { // get item Utils.BarcodeInformation item = adapter.GetItem(index); // serialize writer settings string xmlBarcode = Utils.SerializeBarcodeWriterSettings(item.BarcodeWriterSetting); // create java list for four strings ArrayList serializedStruct = new ArrayList(); serializedStruct.Add(xmlBarcode); serializedStruct.Add(item.BarcodeDescription); serializedStruct.Add(item.BarcodeSubsetName); serializedStruct.Add(item.BarcodeValue); // add serialized object to the temp list list.Add(serializedStruct); } // create java list using (ArrayList arrayList = new ArrayList(list)) { // write java serializable objects to the file outStream.WriteObject(arrayList); } outStream.Close(); } fileStream.Close(); } } catch (Exception e) { Toast.MakeText(this, string.Format("Save history error: {0}", e.Message), ToastLength.Long).Show(); LogUnhandledException(e); } } }
private void WriteObjectDummy(Java.IO.ObjectOutputStream destination) { destination.WriteObject(renderingInfo); destination.WriteUTF(renderingData); }
public static void writeObject(this Java.IO.ObjectOutputStream stream, Java.Lang.Object value) { stream.WriteObject(value); }