private dynamic GetGameLexForTwoWordEntity(int pos1, int pos2) { var twoWordEntity = _commandAggregatesRepo.AllTokensAggregate.Get()[pos1].word + _commandAggregatesRepo.AllTokensAggregate.Get()[pos1].after + _commandAggregatesRepo.AllTokensAggregate.Get()[pos2].word; foreach (var gameLex in _gameLexesRepo.GetAllNestedRepos()) { var result = gameLex.FindFirstBy(a => { if (a.name == twoWordEntity) { return(true); } if (!((IEnumerable <string>)a.synonyms).IsNullOrEmpty()) { return(a.synonyms.Contains(twoWordEntity)); } if (!((IEnumerable <string>)a.equivalenceClasses).IsNullOrEmpty()) { return(a.equivalenceClasses.Contains(twoWordEntity)); } return(false); }); if (result != null) { return(result); } } return(null); }
protected override bool IsValid(PropertyValidatorContext context) { var tokens = context.PropertyValue as IList <Token>; dynamic result1 = null; dynamic result2 = null; int i = 0; while (i < tokens.Count) { foreach (var gameLex in _lexRepo.GetAllNestedRepos()) { if (i < tokens.Count - 1) { var twoTokenWordToCheck = tokens[i].word + tokens[i].after + tokens[i + 1].word; result1 = gameLex.FindFirstBy(a => DoMatchCheck(a, twoTokenWordToCheck) ); if (result1 != null) { _wordsFoundInGameLexes[twoTokenWordToCheck] = result1; _wordsFoundAt.Add(i); _wordsFoundAt.Add(i + 1); break; } } var wordToCheck = tokens[i].word; result2 = gameLex.FindFirstBy(a => DoMatchCheck(a, wordToCheck) ); if (result2 != null) { _wordsFoundInGameLexes[wordToCheck] = result2; _wordsFoundAt.Add(i); break; } } if (result1 != null) { i += 2; } if (result2 != null) { i++; } if (result1 == null && result2 == null) { i++; } result1 = null; result2 = null; } for (int j = 0; j < tokens.Count; j++) { if (!(_wordsFoundAt.Contains(j))) { _tokensNotFoundInGameLexes.Add(tokens[j]); } } if (_tokensNotFoundInGameLexes.Count > 0) { return(false); } return(true); }