Exemple #1
0
 /// <summary>
 /// Determimes whether the values are equal.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(NonNullable <T> other) => Equals(other.Value);
        /// <summary>
        /// Adds a key/value pair to the dictionary.
        /// </summary>
        /// <typeparam name="TK">key type</typeparam>
        /// <typeparam name="TV">value type</typeparam>
        /// <param name="dictionary"></param>
        /// <param name="key"></param>
        /// <param name="addFunc">add function</param>
        /// <param name="updateFunc">update function</param>
        /// <returns>The new value for the key.</returns>
        /// <remarks>
        /// Add or updates the key/value pair to the dictionary.
        /// </remarks>
        private static TV AddOrUpdateInternal <TK, TV>(IDictionary <TK, TV> dictionary, TK key, NonNullable <Func <TK, TV> > addFunc, NonNullable <Func <TK, TV, TV> > updateFunc)
        {
            dictionary[key] = !dictionary.ContainsKey(key)
                ? addFunc.Value.Invoke(key)
                : updateFunc.Value.Invoke(key, dictionary[key]);

            return(dictionary[key]);
        }