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

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

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

revision 94 by william, Sun Mar 10 08:45:58 2013 UTC revision 98 by william, Sun Mar 10 10:13:16 2013 UTC
# Line 17  namespace libxmltv.Core Line 17  namespace libxmltv.Core
17          public PropertyCollection() : this(new List<T>()) { }          public PropertyCollection() : this(new List<T>()) { }
18          public PropertyCollection(ICollection<T> collection) { foreach (var t in collection) { items.Add(t); } }          public PropertyCollection(ICollection<T> collection) { foreach (var t in collection) { items.Add(t); } }
19          public int PropertyCount { get { return items.Count; } }          public int PropertyCount { get { return items.Count; } }
20          public bool IsReadOnly { get { return (items as ICollection<T>).IsReadOnly; } }  
21            public bool IsReadOnly
22            {
23                get
24                {
25                    ICollection<T> collection = (items as ICollection<T>);
26                    if (collection == null)
27                    {
28                        throw new InvalidCastException(string.Format("Unable to cast: '{0}' to '{1}'", items.GetType().Name, typeof(ICollection<T>).Name));
29                    }
30                    return collection.IsReadOnly;
31                }
32            }
33    
34          public void AddProperty(T item) { items.Add(item); }          public void AddProperty(T item) { items.Add(item); }
35          public void ClearProperties() { items.Clear(); }          public void ClearProperties() { items.Clear(); }
36          public bool ContainsProperty(T item) { return items.Contains(item); }          public bool ContainsProperty(T item) { return items.Contains(item); }
# Line 26  namespace libxmltv.Core Line 39  namespace libxmltv.Core
39          public IEnumerator<T> GetEnumerator() { return items.GetEnumerator(); }          public IEnumerator<T> GetEnumerator() { return items.GetEnumerator(); }
40          System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return items.GetEnumerator(); }          System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return items.GetEnumerator(); }
41      }      }
42      public class PropertyDictionary : PropertyDictionary<string, object>      public class PropertyDictionary : PropertyDictionary<string, object>, IPropertyDictionary
43      {      {
44          public PropertyDictionary() : base() { }          public PropertyDictionary() : base() { }
45          public PropertyDictionary(IPropertyDictionary dictionary) : base(dictionary) { }          public PropertyDictionary(IPropertyDictionary dictionary) : base(dictionary) { }
# Line 116  namespace libxmltv.Core Line 129  namespace libxmltv.Core
129          public bool RemoveProperty(TKey key) { return properties.Remove(key); }          public bool RemoveProperty(TKey key) { return properties.Remove(key); }
130          public bool TryGetPropertyValue(TKey key, out TValue value) { return properties.TryGetValue(key, out value); }          public bool TryGetPropertyValue(TKey key, out TValue value) { return properties.TryGetValue(key, out value); }
131          public int PropertyCount { get { return properties.Count; } }          public int PropertyCount { get { return properties.Count; } }
132          public bool IsReadOnly { get { return (properties as ICollection<TKey>).IsReadOnly; } }          public bool IsReadOnly
133            {
134                get
135                {
136                    IDictionary<TKey, TValue> collection = (properties as IDictionary<TKey, TValue>);
137                    if (collection == null)
138                    {
139                        throw new InvalidCastException(string.Format("Unable to cast: '{0}' to '{1}'", properties.GetType().Name, typeof(IDictionary<TKey, TValue>).Name));
140                    }
141                    return collection.IsReadOnly;
142                }
143            }
144          public void AddProperty(PropertyValuePair<TKey, TValue> item) { AddProperty(item.Name, item.Value); }          public void AddProperty(PropertyValuePair<TKey, TValue> item) { AddProperty(item.Name, item.Value); }
145          public void ClearProperties() { properties.Clear(); }          public void ClearProperties() { properties.Clear(); }
146          public bool ContainsProperty(PropertyValuePair<TKey, TValue> item) { return ContainsProperty(item.Name); }          public bool ContainsProperty(PropertyValuePair<TKey, TValue> item) { return ContainsProperty(item.Name); }

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

  ViewVC Help
Powered by ViewVC 1.1.22