internal virtual bool ExistsInFirst(TFirst value) { if (FirstToSecondDictionary.ContainsKey(value)) { return(true); } return(false); }
internal void AddValue(TFirst firstValue, TSecond secondValue) { FirstToSecondDictionary.Add(firstValue, secondValue); if (!SecondToFirstDictionary.ContainsKey(secondValue)) { SecondToFirstDictionary.Add(secondValue, firstValue); } }
// ******************************************************************* /// <summary> /// This method indicates wether a value exists as a 1st relation. /// </summary> /// <param name="value">The value to use for the operation.</param> /// <returns>true if the value exists; false otherwise.</returns> public virtual bool ExistsInFirst( TFirst value ) { // Validate the parameter before attempting to use it. new Guard().ThrowIfNull(value, nameof(value)); // Does the value exist in the internal dictionary? if (FirstToSecondDictionary.ContainsKey(value)) { return(true); } // Not there. return(false); }
// ******************************************************************* // 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 ); } }