/// <summary> /// Method for removing a specified ContentObject from the list /// </summary> /// <param name="contentObj">ContentObject to remove</param> public void Remove(ContentObject contentObj) { //check to see if the list contains this item, if not - exit the procedure if (!((IList)this).Contains(contentObj)) return; //loop through all the items in the list for (int i = 0; i <= this.InnerList.Count; i++) { //create an instance of the ContentObject ContentObject item = (ContentObject)this.InnerList[i]; //check to see if its in the list if ((item.CompareTo(contentObj) == 0)) { //if its in the list remove it this.RemoveAt(i); return; } } }
/// <summary> /// Method for adding an ContentObject to the list /// </summary> /// <param name="contentObj">ContentObject to add</param> public void Add(ContentObject contentObj) { //add this item to the list this.InnerList.Add(contentObj); }
private ContentObjectList ParseResultByType(string content, int numOfCols, bool isCollectionType) { //Get the lines of the content string[] lines = content.Split('\n'); int noOfLines = lines.Length; //If empty query if (noOfLines == 1) { return null; } else { ContentObject contentObj; contentObjList = new ContentObjectList(); for (int i = 1; i < noOfLines - 1; i++) { string[] tokens = lines[i].Split(','); if (numOfCols == 4) { //Hard coded to deal with member/isCollection/label/mimetype format of result string member = tokens[0].Substring(tokens[0].LastIndexOf('/') + 1); string isCollection = tokens[1]; bool isCollectionBool = bool.Parse(isCollection); string label = tokens[2]; string mimetype = tokens[3]; if (isCollectionBool == isCollectionType) { contentObj = new ContentObject(member, isCollectionBool, label, mimetype); contentObjList.Add(contentObj); } } if (numOfCols == 5) { //Hard coded to deal with member/isCollection/label/mimetype format of result string member = tokens[0].Substring(tokens[0].LastIndexOf('/') + 1); string subMember = tokens[1].Substring(tokens[1].LastIndexOf('/') + 1); string isCollection = tokens[2]; bool isCollectionBool = bool.Parse(isCollection); string label = tokens[3]; string mimetype = tokens[4]; if (isCollectionBool == isCollectionType) { contentObj = new ContentObject(subMember, isCollectionBool, label, mimetype); contentObjList.Add(contentObj); } } } return contentObjList; } }