/// <summary> /// Gets the value of the item with the specified name. /// </summary> /// <param name="name">Name to get the value for.</param> /// <returns>Value for the name, or null if not found.</returns> public string this[string name] { [CanBeNull] get { string ret; TryGetValue(name, out ret); return(ret); } [NotNull] set { int idx; NameValuePair old = null; var nvp = new NameValuePair(name, value); if (v2Coll == null) { idx = unboundDict.FindIndex(p => p.Name == name); if (idx == -1) { unboundDict.Add(nvp); } else { old = unboundDict[idx]; unboundDict[idx] = nvp; } } else { var array = new KeyValuePair <string, string> [Count]; ((ICollection <KeyValuePair <string, string> >) this).CopyTo(array, 0); idx = Array.FindIndex(array, p => p.Key == name); if (idx == -1) { v2Coll.Create(name, value); } else { old = array[idx]; array[idx] = new KeyValuePair <string, string>(name, value); v2Coll.Clear(); foreach (KeyValuePair <string, string> t in array) { v2Coll.Create(t.Key, t.Value); } } } if (idx == -1) { OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, nvp)); } else { OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, nvp, old, idx)); } } }
internal void Bind(ITaskNamedValueCollection iTaskNamedValueCollection) { v2Coll = iTaskNamedValueCollection; v2Coll.Clear(); foreach (var item in unboundDict) { v2Coll.Create(item.Key, item.Value); } }
internal void Bind([NotNull] ITaskNamedValueCollection iTaskNamedValueCollection) { v2Coll = iTaskNamedValueCollection; v2Coll.Clear(); foreach (var item in unboundDict) { v2Coll.Create(item.Name, item.Value); } }
internal void Bind(ITaskNamedValueCollection iTaskNamedValueCollection) { _v2Coll = iTaskNamedValueCollection; _v2Coll.Clear(); foreach (KeyValuePair <string, string> pair in _unboundDict) { _v2Coll.Create(pair.Key, pair.Value); } }
/// <summary> /// Adds a name-value pair to the collection. /// </summary> /// <param name="Name"> The name associated with a value in a name-value pair. </param> /// <param name="Value"> The value associated with a name in a name-value pair. </param> public void Add(string Name, string Value) { if (v2Coll != null) { v2Coll.Create(Name, Value); } else { unboundDict.Add(Name, Value); } }