141 |
return collection.IsReadOnly; |
return collection.IsReadOnly; |
142 |
} |
} |
143 |
} |
} |
144 |
public void AddProperty(PropertyValuePair<TKey, TValue> item) { AddProperty(item.Name, item.Value); } |
public void AddProperty(IPropertyValuePair<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(IPropertyValuePair<TKey, TValue> item) { return ContainsProperty(item.Name); } |
147 |
public void CopyPropertiesTo(PropertyValuePair<TKey, TValue>[] array, int arrayIndex) |
public void CopyPropertiesTo(IPropertyValuePair<TKey, TValue>[] array, int arrayIndex) |
148 |
{ |
{ |
149 |
var list = properties.ToList().Cast<PropertyValuePair<TKey, TValue>>().ToList(); |
var list = properties.ToList().Cast<IPropertyValuePair<TKey, TValue>>().ToList(); |
150 |
list.CopyTo(array, arrayIndex); |
list.CopyTo(array, arrayIndex); |
151 |
} |
} |
152 |
public bool RemoveProperty(PropertyValuePair<TKey, TValue> item) { return RemoveProperty(item.Name); } |
public bool RemoveProperty(IPropertyValuePair<TKey, TValue> item) { return RemoveProperty(item.Name); } |
153 |
IEnumerator<PropertyValuePair<TKey, TValue>> IEnumerable<PropertyValuePair<TKey, TValue>>.GetEnumerator() { return new PropertyDictionaryEnumerator(this, 2); } |
IEnumerator<IPropertyValuePair<TKey, TValue>> IEnumerable<IPropertyValuePair<TKey, TValue>>.GetEnumerator() { return new PropertyDictionaryEnumerator(this, 2); } |
154 |
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return properties.GetEnumerator(); } |
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return properties.GetEnumerator(); } |
155 |
|
|
156 |
#region enumerator support |
#region enumerator support |
157 |
public class PropertyDictionaryEnumerator: IEnumerator<PropertyValuePair<TKey,TValue>>, IDisposable |
public class PropertyDictionaryEnumerator : IEnumerator<IPropertyValuePair<TKey, TValue>>, IDisposable |
158 |
{ |
{ |
159 |
private PropertyDictionary<TKey, TValue> dictionary; |
private PropertyDictionary<TKey, TValue> dictionary; |
160 |
private int index; |
private int index; |
161 |
private PropertyValuePair<TKey, TValue> current; |
private IPropertyValuePair<TKey, TValue> current; |
162 |
private int getEnumeratorRetType; |
private int getEnumeratorRetType; |
163 |
internal const int DictEntry = 1; |
internal const int DictEntry = 1; |
164 |
internal const int KeyValuePair = 2; |
internal const int KeyValuePair = 2; |
172 |
this.current = new PropertyValuePair<TKey, TValue>(); |
this.current = new PropertyValuePair<TKey, TValue>(); |
173 |
} |
} |
174 |
|
|
175 |
public PropertyValuePair<TKey, TValue> Current |
public IPropertyValuePair<TKey, TValue> Current |
176 |
{ |
{ |
177 |
get { return this.current; } |
get { return this.current; } |
178 |
} |
} |
207 |
{ |
{ |
208 |
if (this.dictionary.entries[this.index].hashCode >= 0) |
if (this.dictionary.entries[this.index].hashCode >= 0) |
209 |
{ |
{ |
210 |
this.current = new KeyValuePair<TKey, TValue>(this.dictionary.entries[this.index].name, this.dictionary.entries[this.index].value); |
this.current =(IPropertyValuePair<TKey,TValue>)(PropertyValuePair<TKey,TValue>)new KeyValuePair<TKey, TValue>(this.dictionary.entries[this.index].name, this.dictionary.entries[this.index].value); |
211 |
this.index++; |
this.index++; |
212 |
return true; |
return true; |
213 |
} |
} |
224 |
ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumFailedVersion); |
ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumFailedVersion); |
225 |
} |
} |
226 |
this.index = 0; |
this.index = 0; |
227 |
this.current = new KeyValuePair<TKey, TValue>(); |
this.current = (IPropertyValuePair<TKey, TValue>)(PropertyValuePair<TKey, TValue>)new KeyValuePair<TKey, TValue>(); |
228 |
} |
} |
229 |
} |
} |
230 |
#endregion |
#endregion |