/// <summary> /// Returns all order detail objects stored in a given file /// </summary> /// <param name="sourceFile">storage file</param> /// <returns>Readonly list of all oredr detail records deserialized from storage file</returns> public static ReadOnlyCollection <OrderDetail> GetList(string sourceFile) { var list = new List <OrderDetail>(); using (var rdr = new OrderDetailsReader(sourceFile)) { do { var det = rdr.GetNextItem(); if (det != null) { list.Add(det); } } while (!rdr.EOF); } return(list.AsReadOnly()); }
/// <summary> /// Returns all order detail object row indexes stored in a given file /// </summary> /// <param name="sourceFile">storage file</param> /// <returns>Array of all oredr detail record indexes deserialized from storage file</returns> public static int[] GetRowIdxList(string sourceFile) { var lst = new List <int>(); using (var rdr = new OrderDetailsReader(sourceFile)) { do { var data = rdr.GetNextRow(out Guid id); if (data != null && id != Guid.Empty) { lst.Add(int.Parse(data[3])); } } while (!rdr.EOF); } return(lst.ToArray()); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var rbHandler = new System.EventHandler(this.Rb_CheckedChanged); this.rbSizeOnly.CheckedChanged += rbHandler; this.rbLRU.CheckedChanged += rbHandler; this.rbMRU.CheckedChanged += rbHandler; this.rbSizesAndCustomStrategy.CheckedChanged += rbHandler; lblDataFile.Text = OrderDetailsReader.GetDefaultSourceFile(); if (!File.Exists(lblDataFile.Text)) { BtnLoad.Enabled = false; } else { lblFileMessage.Text = C_DefaultFileMSG; } CalcSizes(); }
/// <summary> /// Returns order detail object for a given storage file and detail index /// </summary> /// <param name="sourceFile">Storage file</param> /// <param name="rowIndex">Order detail index</param> /// <returns></returns> public static OrderDetail Get(string sourceFile, int rowIndex) { if (rowIndex < 0) { return(null); } using (var rdr = new OrderDetailsReader(sourceFile)) { do { var data = rdr.GetNextRow(out Guid id); if (data != null && id != Guid.Empty) { if (int.Parse(data[3]) == rowIndex) { return(new OrderDetail(data)); } } } while (!rdr.EOF); } return(null); }