Humility/Query/HUMQuery_Root.cs
/// <summary>
/// Removes all unused values from one dictionary, that don't exist in another.
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
Removes all unused values from one dictionary, that don't exist in another.
Removes all unused values from one dictionary that don ' t exist in another .
public static void Undefine<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Dictionary<TKey, TValue> deserializedDictionary, Action<TValue> onRemoved, ref bool isNew)
        {
            if (!isNew)
            {
                var keys = deserializedDictionary.Keys.ToList();
                var values = deserializedDictionary.Values.ToList();
                for (int i = 0; i < deserializedDictionary.Count; i++)
                {
                    if (!dictionary.ContainsKey(keys[i]))
                    {
                        var value = deserializedDictionary[keys[i]];
                        deserializedDictionary.Remove(keys[i]);
                        onRemoved(value);
                    }
                }
            }
            isNew = true;
        }
public static void Undefine < TKey , TValue > ( this Dictionary < TKey , TValue > dictionary , Dictionary < TKey , TValue > deserializedDictionary , Action < TValue > onRemoved , ref bool isNew ) { if ( ! isNew ) { var keys = deserializedDictionary . Keys . ToList ( ) ; var values = deserializedDictionary . Values . ToList ( ) ; for ( int i = 0 ; i < deserializedDictionary . Count ; i ++ ) { if ( ! dictionary . ContainsKey ( keys [ i ] ) ) { var value = deserializedDictionary [ keys [ i ] ] ; deserializedDictionary . Remove ( keys [ i ] ) ; onRemoved ( value ) ; } } } isNew = true ; }
Removes all unused values from one dictionary, that don't exist in another.
Removes all unused values from one dictionary that don ' t exist in another .
Dictionary<TKey, TValue>
this
deserializedDictionary
Dictionary<TKey, TValue>
onRemoved
Action<TValue>
bool
ref
typeparam
None
typeparam
None