#region Copyright 2012-2014 by Roger Knapp, Licensed under the Apache License, Version 2.0 /* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System; using System.Collections.Generic; namespace CSharpTest.Net.Collections { /// /// Extends the IDictionary interface to encompass the TryXxxx operations /// public interface IDictionaryEx : IDictionary, IDisposable { /// /// Adds a key/value pair to the if the key does not already exist. /// /// The key of the element to add. /// The value to be added, if the key does not already exist. /// The is read-only. TValue GetOrAdd(TKey key, TValue value); /// /// Adds an element with the provided key and value to the . /// /// The object to use as the key of the element to add. /// The object to use as the value of the element to add. /// The is read-only. bool TryAdd(TKey key, TValue value); /// /// Updates an element with the provided key to the value if it exists. /// /// Returns true if the key provided was found and updated to the value. /// The object to use as the key of the element to update. /// The new value for the key if found. /// The is read-only. bool TryUpdate(TKey key, TValue value); /// /// Updates an element with the provided key to the value if it exists. /// /// Returns true if the key provided was found and updated to the value. /// The object to use as the key of the element to update. /// The new value for the key if found. /// The value that is compared to the value of the element with key. /// The is read-only. bool TryUpdate(TKey key, TValue value, TValue comparisonValue); /// /// Removes the element with the specified key from the . /// /// /// true if the element is successfully removed; otherwise, false. This method also returns false if was not found in the original . /// /// The key of the element to remove. /// The value that was removed. /// The is read-only. bool TryRemove(TKey key, out TValue value); } }