public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { if (!fileSystemInfo.Extension.Equals(".csproj", StringComparison.OrdinalIgnoreCase) && !fileSystemInfo.Extension.Equals(".vbproj", StringComparison.OrdinalIgnoreCase)) { return(false); } var directory = Path.GetDirectoryName(fileSystemInfo.FullName); if (directory == null) { return(false); } var xml = XDocument.Load(fileSystemInfo.FullName); var manager = new XmlNamespaceManager(new NameTable()); manager.AddNamespace("ns", "http://schemas.microsoft.com/developer/msbuild/2003"); var elements = xml.XPathSelectElements("//ns:Project/ns:ItemGroup/ns:Reference", manager); foreach (var reference in elements) { var assemblyName = (string)reference.Attribute("Include"); var location = (string)reference.Element("{http://schemas.microsoft.com/developer/msbuild/2003}HintPath"); var fullHintPath = location != null?Path.GetFullPath(Path.Combine(directory, location)) : null; if (IsMatch(assemblyName, fullHintPath)) { return(true); } } return(false); }
public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { var file = (FileInfo)fileSystemInfo; return((_minLengthInBytes == null || file.Length >= _minLengthInBytes.Value) && (_maxLengthInBytes == null || file.Length <= _maxLengthInBytes.Value)); }
public override bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { // Normal match if (base.IsMatch(fileSystemInfo, context)) { return(true); } // Should be ending with .ZIP if (string.IsNullOrEmpty(fileSystemInfo.Extension) || !fileSystemInfo.Extension.Equals(".zip", StringComparison.OrdinalIgnoreCase)) { return(false); } // All found entries in the ZIP file. var myContext = (ZipCriterionContext)context; using (var zip = ZipFile.Read(fileSystemInfo.FullName)) { foreach (var entry in zip.EntryFileNames.Select(e => e.Replace('/', '\\'))) { if (IsMatch(this.MatchFullPath ? Path.Combine(fileSystemInfo.FullName, entry) : Path.GetFileName(entry))) { myContext.Childs.Add(entry); } } } return(myContext.Childs.Count > 0); }
public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { DateTime dateTimeUtc; switch (_dateOption) { case FileDateOption.Accessed: dateTimeUtc = fileSystemInfo.LastAccessTimeUtc; break; case FileDateOption.Changed: dateTimeUtc = fileSystemInfo.LastWriteTimeUtc; break; case FileDateOption.Created: dateTimeUtc = fileSystemInfo.CreationTimeUtc; break; default: throw new NotSupportedException(); } return((_startDateTime == null || dateTimeUtc >= _startDateTime.Value) && (_endDateTime == null || dateTimeUtc <= _endDateTime.Value)); }
public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { return(IsMatch(_matchFullPath ? fileSystemInfo.FullName : fileSystemInfo.Name)); }
public virtual bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { var name = this.MatchFullPath ? fileSystemInfo.FullName : fileSystemInfo.Name; return(IsMatch(name)); }
public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { return(_container.Add((FileInfo)fileSystemInfo)); }
public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { return((fileSystemInfo.Attributes & _includedAttributes) == _includedAttributes && (fileSystemInfo.Attributes & _excludedAttributes) == 0); }
public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { return(_script.IsMatch(fileSystemInfo.FullName)); }
public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { var fileInfo = (FileInfo)fileSystemInfo; var buffer = new byte[BufferSize]; var textLength = _text.Length; Encoding[] encodings = new Encoding[1]; // Check multiple encodings for (int encodingIndex = 0; encodingIndex < encodings.Length; encodingIndex++) { // Encoding for current loop. First try will be NULL. Encoding encoding = encodings[encodingIndex]; bool characterShouldBeNonWord = false; char characterBefore = '\0'; using (var stream = fileInfo.OpenRead()) { int length; int foundMatchingSymbols = 0; while ((length = stream.Read(buffer, 0, BufferSize)) > 0) { // If encoding is not yet determined, detect it now. if (encoding == null) { encodings = _encodingFactory.DetectEncoding(buffer); encoding = encodings[encodingIndex]; } var currentString = encoding.GetString(buffer, 0, length); var currentStringLength = currentString.Length; // Cache bool startAtBegin = foundMatchingSymbols > 0; var charIndex = 0; // The first character should be a non-word character if the prev bytes read are ending with a matching string. if (_matchFullWords && characterShouldBeNonWord && currentStringLength > 0) { characterShouldBeNonWord = false; if (!CharIsWordChar(currentString[0])) { return(true); } } // Check if the first or next matching symbol is in the current string. if ((charIndex = currentString.IndexOfAny(_textInChars[foundMatchingSymbols], charIndex)) >= 0) { do { // Assign the character before. if (charIndex > 0 && foundMatchingSymbols == 0 && _matchFullWords) { characterBefore = currentString[charIndex - 1]; } // Not first character of the _text, so check if the second char is at the first position. if (startAtBegin) { startAtBegin = false; if (charIndex > 0) // Letter should be at the first position! Of not, start over from the first char in _text. { foundMatchingSymbols = 0; continue; } } // Copy the variable, so it won't be changed in the loop below. var current = charIndex; // Try to match as many of characters as possible. while (++foundMatchingSymbols < textLength && currentStringLength > ++current && (currentString[current] == _text[foundMatchingSymbols] || _ignoreCase && _textInChars[foundMatchingSymbols].Any(c => c == currentString[current]))) { ; } // Found it! if (foundMatchingSymbols == textLength && (!_matchFullWords || !CharIsWordChar(characterBefore))) { if (_matchFullWords) { // Try to figure out next read if the string ends with a non-word char. if (current >= currentStringLength - 1) { characterShouldBeNonWord = true; } // Check if the next letter is not a word char. If not, return true. Else make sure that the current is +1 so it will be reset in the next IF statement. else if (!CharIsWordChar(currentString[++current])) { return(true); } } else { // Retrurn true of it not checking for words instead part of a string. return(true); } } // Reset the matching symbols counter if the end of the current string is not reached. If it is, continue testing on the next read. if (currentStringLength != current) { foundMatchingSymbols = 0; } // Check if the next matching symbol is in the current string. } while ((charIndex = currentString.IndexOfAny(_textInChars[foundMatchingSymbols], ++charIndex)) >= 0); // Assign the last character, so in the next round it knows the character before. if (foundMatchingSymbols == 0 && _matchFullWords) { characterBefore = currentString[currentStringLength - 1]; } } else { foundMatchingSymbols = 0; // Reasign the character before to the last char in the string. if (_matchFullWords) { characterBefore = currentString[currentStringLength - 1]; } } } if (_matchFullWords && characterShouldBeNonWord) { return(true); } } } return(false); }
public bool IsMatch(FileSystemInfo fileSystemInfo, ICriterionContext context) { var fileInfo = (FileInfo)fileSystemInfo; throw new NotImplementedException(); }