2 using System.Collections;
3 using System.Collections.Generic;
5 using System.Xml.Serialization;
6 using System.Runtime.InteropServices;
17 public class SerialisableList<T> : IEnumerable<T>, ICloneable
19 private List<T> _list =
new List<T>();
22 public T
this[
int index] {
get {
return _list[index]; } set { _list[index] = value; } }
23 public int Count {
get {
return _list.Count; } }
31 public void Add(T item)
40 public void AddRange(IEnumerable<T> collection)
42 _list.AddRange(collection);
50 public void Insert(
int index, T item)
52 _list.Insert(index, item);
65 _list.RemoveAt(index);
75 return _list.Remove(item);
85 _list.RemoveRange(index, count);
95 return _list.RemoveAll(match);
108 #region Other standard stuff
118 return _list.GetRange(index, count);
128 return _list.Contains(item);
137 return _list.ToArray();
142 #region IEnumerable<T> Members
151 for (
int i = 0; i < _list.Count; ++i)
153 yield
return _list[i];
163 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
165 return GetEnumerator();
170 #region ICloneable Members
182 for (
int i = 0; i < _list.Count; ++i)
184 itemClone = _list[i];
185 deepcopy.Add(itemClone);
193 #region Serialisation Code
203 return _list.ToArray();
209 _list =
new List<T>(value);
void Clear()
Wrapper for standard List "Clear" - removes all items.
void RemoveAt(int index)
Wrapper for standard List "RemoveAt".
void AddRange(IEnumerable< T > collection)
Wrapper for standard List "Add".
void Add(T item)
Wrapper for standard List "Add".
object Clone()
Clone - default method of ICloneable. Produces a deep-copy of the List.
void Insert(int index, T item)
Wrapper for standard List "Insert".
Boolean Remove(T item)
Wrapper for standard List "Remove".
int RemoveAll(Predicate< T > match)
Wrapper for standard List "RemoveAll". Removes all items that match the specified predicate...
Boolean Contains(T item)
Wrapper for standard List "Contains".
List< T > GetRange(int index, int count)
Wrapper for standard List "GetRange" - returns all items in a specified range.
void RemoveRange(int index, int count)
Wrapper for standard List "RemoveRange".
Specialised generic version of the standard List class which can be converted to XML. Containss a standard List object and has wrapper methods for most of the standard List functionality plus some extras.
IEnumerator< T > GetEnumerator()
GetEnumerator - default method of IEnumerable. Provides an iterator over a generic List...
T[] ToArray()
Wrapper for standard List "ToArray".