public static NRCRecord FindRecord(this INRCDictionary dictionary, IWordItem word) { NRCRecord nrcRecord = null; foreach (var text in word.GetPossibleText()) { nrcRecord = dictionary.FindRecord(text); if (nrcRecord != null) { break; } } if (nrcRecord == null) { return(null); } nrcRecord = (NRCRecord)nrcRecord.Clone(); if (word.Relationship?.Inverted != null) { nrcRecord.Invert(); } return(nrcRecord); }
public static bool TryGetWordValue <T>(this IDictionary <string, T> table, IWordItem word, out T value) { if (table == null) { throw new System.ArgumentNullException(nameof(table)); } if (word == null) { throw new System.ArgumentNullException(nameof(word)); } value = default; foreach (var text in word.GetPossibleText()) { if (table.TryGetValue(text, out value)) { return(true); } } return(false); }