/[xmltv_parser]/trunk/libxmltv/Core/PropertyList.cs
ViewVC logotype

Diff of /trunk/libxmltv/Core/PropertyList.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 97 by william, Sun Mar 10 09:43:49 2013 UTC revision 98 by william, Sun Mar 10 10:13:16 2013 UTC
# Line 14  namespace libxmltv.Core Line 14  namespace libxmltv.Core
14      }      }
15      public class PropertyList<TKey, TValue> : IPropertyList<TKey, TValue>      public class PropertyList<TKey, TValue> : IPropertyList<TKey, TValue>
16      {      {
17          private List<PropertyValuePair<TKey, TValue>> properties;          private PropertyCollection<PropertyValuePair<TKey, TValue>> properties;
18          public PropertyList() { properties = new List<PropertyValuePair<TKey, TValue>>(); }          public PropertyList() { properties = new PropertyCollection<PropertyValuePair<TKey, TValue>>(); }
19          public PropertyList(IEnumerable<PropertyValuePair<TKey, TValue>> collection) { properties = new List<PropertyValuePair<TKey, TValue>>(collection); }          public PropertyList(IEnumerable<PropertyValuePair<TKey, TValue>> collection) : this() { foreach (var p in collection) { properties.AddProperty(p); } }
20          public PropertyList(int capacity) { properties = new List<PropertyValuePair<TKey, TValue>>(); }          public PropertyList(int capacity)
21          public PropertyValuePair<TKey, TValue> this[int index] { get { return properties[index]; } set { properties[index] = value; } }          {
22          public int IndexOfProperty(PropertyValuePair<TKey, TValue> item) { return properties.IndexOf(item); }              properties = new PropertyCollection<PropertyValuePair<TKey, TValue>>();
23          public void InsertPropertyAtIndex(int index, PropertyValuePair<TKey, TValue> item) { properties.Insert(index, item); }          }
24          public void RemovePropertyAt(int index) { properties.RemoveAt(index); }          public PropertyValuePair<TKey, TValue> this[int index] { get { return properties.ToList()[index]; } set { properties.ToList()[index] = value; } }
25          public int PropertyCount { get { return properties.Count; } }          public int IndexOfProperty(PropertyValuePair<TKey, TValue> item) { return properties.ToList().IndexOf(item); }
26          public bool IsReadOnly { get { return (properties as IPropertyCollection<TKey>).IsReadOnly; } }          public void InsertPropertyAtIndex(int index, PropertyValuePair<TKey, TValue> item) { properties.ToList().Insert(index, item); }
27          public void AddProperty(PropertyValuePair<TKey, TValue> item) { properties.Add(item); }          public void RemovePropertyAt(int index) { properties.RemoveProperty(this[index]); }
28          public void ClearProperties() { properties.Clear(); }          public int PropertyCount { get { return properties.PropertyCount; } }
29            public bool IsReadOnly
30            {
31                get
32                {
33                    IPropertyCollection<PropertyValuePair<TKey, TValue>> collection = (properties as IPropertyCollection<PropertyValuePair<TKey, TValue>>);
34                    if(collection == null)
35                    {
36                        throw new InvalidCastException(string.Format("Unable to cast: '{0}' to '{1}'", properties.GetType().Name, typeof(IPropertyCollection<PropertyValuePair<TKey, TValue>>).Name));
37                    }
38                    return collection.IsReadOnly;
39                }
40            }
41            public void AddProperty(PropertyValuePair<TKey, TValue> item) { properties.AddProperty(item); }
42            public void ClearProperties() { properties.ClearProperties(); }
43          public bool ContainsProperty(PropertyValuePair<TKey, TValue> item) { return properties.Contains(item); }          public bool ContainsProperty(PropertyValuePair<TKey, TValue> item) { return properties.Contains(item); }
44          public void CopyPropertiesTo(PropertyValuePair<TKey, TValue>[] array, int arrayIndex) { properties.CopyTo(array, arrayIndex); }          public void CopyPropertiesTo(PropertyValuePair<TKey, TValue>[] array, int arrayIndex) { properties.CopyPropertiesTo(array, arrayIndex); }
45          public bool RemoveProperty(PropertyValuePair<TKey, TValue> item) { return properties.Remove(item); }          public bool RemoveProperty(PropertyValuePair<TKey, TValue> item) { return properties.RemoveProperty(item); }
46          public IEnumerator<PropertyValuePair<TKey, TValue>> GetEnumerator() { return properties.GetEnumerator(); }          public IEnumerator<PropertyValuePair<TKey, TValue>> GetEnumerator() { return properties.GetEnumerator(); }
47          System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return this.GetEnumerator(); }          System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
48    

Legend:
Removed from v.97  
changed lines
  Added in v.98

  ViewVC Help
Powered by ViewVC 1.1.22