internal void AddValue(TFirst firstValue, TSecond secondValue) { FirstToSecondDictionary.Add(firstValue, secondValue); if (!SecondToFirstDictionary.ContainsKey(secondValue)) { SecondToFirstDictionary.Add(secondValue, firstValue); } }
// ******************************************************************* // Public methods. // ******************************************************************* #region Public methods /// <summary> /// This method adds a new relationship to the dictionary. /// </summary> /// <param name="firstValue">The 1st value in the relationship.</param> /// <param name="secondValue">The 2nd value in the realtionship.</param> public void AddValue( TFirst firstValue, TSecond secondValue ) { // Validate the parameters before attempting to use them. new Guard().ThrowIfNull(firstValue, nameof(firstValue)) .ThrowIfNull(secondValue, nameof(secondValue)); // Add the relationship to the first dictionary. FirstToSecondDictionary.Add( firstValue, secondValue ); // Should we add the relationship to the second dictionary? if (!SecondToFirstDictionary.ContainsKey(secondValue)) { SecondToFirstDictionary.Add( secondValue, firstValue ); } }