///-------------------------------------------------------------------------------- /// <summary>This method build a page of items in the overall list. The items in the /// list are references to the items in the overall list.</summary> /// /// <param name="pageSize">The size of the page to return.</param> /// <param name="pageIndex">The index of the page into the overall list.</param> /// /// <returns>A SortableDataObjectList containing a reference page of the original list.</returns> ///-------------------------------------------------------------------------------- public virtual SortableDataObjectList <T> ReferencePage(int pageSize, int pageIndex) { SortableDataObjectList <T> listPage = new SortableDataObjectList <T>(); // if the list is not empty and the property is valid, find an item if ((pageSize > 0) && (pageSize < this.Count)) { for (int i = pageIndex; i < this.Count; i++) { if (listPage.Count >= pageSize) { break; } listPage.Add(this[i]); } } return(listPage); }
///-------------------------------------------------------------------------------- /// <summary>This method deserializes a string into an object.</summary> /// /// <param name="inputString">The input string to deserialize.</param> /// <param name="inputList">The list to deserialize into.</param> /// /// <returns>The deserialized object.</returns> ///-------------------------------------------------------------------------------- public static void Deserialize <T>(string inputString, ref SortableDataObjectList <T> inputList) where T : IDataObject, new() { try { if (inputList != null) { // set up input stream XmlReader reader = XmlReader.Create(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(inputString))); // deserialize DataContractSerializer serializer = new DataContractSerializer(inputList.GetType()); inputList = (SortableDataObjectList <T>)serializer.ReadObject(reader); } } catch (Exception ex) { bool reThrow = ExceptionHandler.HandleException(ex); if (reThrow) { throw; } } }