public bool IsSatisfiedBy(List<Episode> episodes) { var episodeIds = episodes.SelectList(e => e.Id); var episodeFileIds = episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFileId).Distinct(); foreach (var episodeFileId in episodeFileIds) { var episodesInFile = _episodeService.GetEpisodesByFileId(episodeFileId); if (episodesInFile.Select(e => e.Id).Except(episodeIds).Any()) { return false; } } return true; }
public void SetupInput(string input) { _i = _j = _current = 0; _chunks = new List<string>(); _input = input.Replace("\r\n", "\n"); _inputLength = _input.Length; // Split the input into chunks, // Either delimited by /\n\n/ or // delmited by '\n}' (see rationale above), // depending on the level of optimization. if (Optimization == 0) _chunks.Add(_input); else { var chunkParts = new List<StringBuilder> { new StringBuilder() }; var chunkPart = chunkParts.Last(); var skip = new Regex(@"\G[^\""'{}/\\`]+"); var comment = new Regex(@"\G\/\*(?:[^*\n]|\*+[^\/\n]|\*?(\n))*\*+\/"); var level = 0; var lastBlock = 0; var lastQuote = 0; char? inString = null; for (int i = 0; i < _inputLength; i++) { var match = skip.Match(_input, i); if(match.Success) { chunkPart.Append(match.Value); i += match.Length; if (i == _inputLength) break; } if(i < _inputLength - 1 && _input[i] == '/') { var cc = _input[i + 1]; if(cc == '/' || cc=='*') { match = comment.Match(_input, i); if (match.Success) { i += match.Length; chunkPart.Append(match.Value); if (i == _inputLength) break; } } } var c = _input[i]; if (c == '"' || c == '\'' || c == '`') { if (inString == null) { inString = c; lastQuote = i; } else inString = inString == c ? null : inString; } else if (inString != null && c == '\\' && i < _inputLength - 1) { chunkPart.Append(_input, i, 2); i++; continue; } else if (inString == null && c == '{') { level++; lastBlock = i; } else if (inString == null && c == '}') { level--; if (level < 0) throw new ParsingException("Unexpected '}'", i); chunkPart.Append(c); chunkPart = new StringBuilder(); chunkParts.Add(chunkPart); continue; } chunkPart.Append(c); } if(inString != null) throw new ParsingException(string.Format("Missing closing quote ({0})", inString), lastQuote); if(level > 0) throw new ParsingException("Missing closing '}'", lastBlock); _chunks = chunkParts.SelectList(p => p.ToString()); _input = _chunks.JoinStrings(""); _inputLength = _input.Length; } Advance(0); // skip any whitespace characters at the start. }