Parent Directory
|
Revision Log
|
Patch
--- trunk/libxmltv/Core/PropertyList.cs 2013/03/10 09:43:49 97 +++ trunk/libxmltv/Core/PropertyList.cs 2013/03/10 10:13:16 98 @@ -14,21 +14,35 @@ } public class PropertyList<TKey, TValue> : IPropertyList<TKey, TValue> { - private List<PropertyValuePair<TKey, TValue>> properties; - public PropertyList() { properties = new List<PropertyValuePair<TKey, TValue>>(); } - public PropertyList(IEnumerable<PropertyValuePair<TKey, TValue>> collection) { properties = new List<PropertyValuePair<TKey, TValue>>(collection); } - public PropertyList(int capacity) { properties = new List<PropertyValuePair<TKey, TValue>>(); } - public PropertyValuePair<TKey, TValue> this[int index] { get { return properties[index]; } set { properties[index] = value; } } - public int IndexOfProperty(PropertyValuePair<TKey, TValue> item) { return properties.IndexOf(item); } - public void InsertPropertyAtIndex(int index, PropertyValuePair<TKey, TValue> item) { properties.Insert(index, item); } - public void RemovePropertyAt(int index) { properties.RemoveAt(index); } - public int PropertyCount { get { return properties.Count; } } - public bool IsReadOnly { get { return (properties as IPropertyCollection<TKey>).IsReadOnly; } } - public void AddProperty(PropertyValuePair<TKey, TValue> item) { properties.Add(item); } - public void ClearProperties() { properties.Clear(); } + private PropertyCollection<PropertyValuePair<TKey, TValue>> properties; + public PropertyList() { properties = new PropertyCollection<PropertyValuePair<TKey, TValue>>(); } + public PropertyList(IEnumerable<PropertyValuePair<TKey, TValue>> collection) : this() { foreach (var p in collection) { properties.AddProperty(p); } } + public PropertyList(int capacity) + { + properties = new PropertyCollection<PropertyValuePair<TKey, TValue>>(); + } + public PropertyValuePair<TKey, TValue> this[int index] { get { return properties.ToList()[index]; } set { properties.ToList()[index] = value; } } + public int IndexOfProperty(PropertyValuePair<TKey, TValue> item) { return properties.ToList().IndexOf(item); } + public void InsertPropertyAtIndex(int index, PropertyValuePair<TKey, TValue> item) { properties.ToList().Insert(index, item); } + public void RemovePropertyAt(int index) { properties.RemoveProperty(this[index]); } + public int PropertyCount { get { return properties.PropertyCount; } } + public bool IsReadOnly + { + get + { + IPropertyCollection<PropertyValuePair<TKey, TValue>> collection = (properties as IPropertyCollection<PropertyValuePair<TKey, TValue>>); + if(collection == null) + { + throw new InvalidCastException(string.Format("Unable to cast: '{0}' to '{1}'", properties.GetType().Name, typeof(IPropertyCollection<PropertyValuePair<TKey, TValue>>).Name)); + } + return collection.IsReadOnly; + } + } + public void AddProperty(PropertyValuePair<TKey, TValue> item) { properties.AddProperty(item); } + public void ClearProperties() { properties.ClearProperties(); } public bool ContainsProperty(PropertyValuePair<TKey, TValue> item) { return properties.Contains(item); } - public void CopyPropertiesTo(PropertyValuePair<TKey, TValue>[] array, int arrayIndex) { properties.CopyTo(array, arrayIndex); } - public bool RemoveProperty(PropertyValuePair<TKey, TValue> item) { return properties.Remove(item); } + public void CopyPropertiesTo(PropertyValuePair<TKey, TValue>[] array, int arrayIndex) { properties.CopyPropertiesTo(array, arrayIndex); } + public bool RemoveProperty(PropertyValuePair<TKey, TValue> item) { return properties.RemoveProperty(item); } public IEnumerator<PropertyValuePair<TKey, TValue>> GetEnumerator() { return properties.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
ViewVC Help | |
Powered by ViewVC 1.1.22 |