├── media ├── site_logo.gif ├── site_logo.png └── site_logo.xcf ├── Everything ├── Everything.dll ├── Everything.exe ├── Everything32.dll └── Everything64.dll ├── EverythingNet.Tests ├── TestData │ └── sound.mp3 ├── packages.config ├── Init.cs ├── Properties │ └── AssemblyInfo.cs ├── LogicalQueryTests.cs ├── MusicSearchTests.cs ├── LogicSearchTests.cs ├── EverythingTests.cs ├── NameQueryableTests.cs ├── SizeSearchTests.cs ├── FileSearchTests.cs ├── EverythingNet.Tests.csproj ├── AcceptanceTests.cs └── DateSearchTests.cs ├── EverythingNet ├── Interfaces │ ├── ResultKind.cs │ ├── IQueryGenerator.cs │ ├── IQueryable.cs │ ├── IMusicQueryable.cs │ ├── INameQueryable.cs │ ├── ISearchResult.cs │ ├── IImageQueryable.cs │ ├── IFileQueryable.cs │ ├── IQuery.cs │ ├── ISizeQueryable.cs │ ├── SortingKey.cs │ ├── IEverything.cs │ └── IDateQueryable.cs ├── packages.config ├── EverythingNet.targets ├── Query │ ├── LogicalQuery.cs │ ├── ImageQueryable.cs │ ├── Query.cs │ ├── Queryable.cs │ ├── MusicQueryable.cs │ ├── NameQueryable.cs │ ├── DateQueryable.cs │ ├── FileQueryable.cs │ └── SizeQueryable.cs ├── EverythingNet.nuspec ├── Extensions │ ├── MacroSearch.cs │ ├── MucisSearch.cs │ ├── SizeSearch.cs │ ├── LogicSearch.cs │ └── DateSearch.cs ├── Properties │ └── AssemblyInfo.cs ├── Core │ ├── EverythingState.cs │ ├── Everything.cs │ ├── SearchResult.cs │ └── EverythingWrapper.cs ├── EverythingNet.csproj └── EverythingNet.R#Settings ├── .gitignore ├── EverythingNet.Bench ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── CombinedQueryBench.cs ├── SimpleQueryBench.cs ├── App.config ├── packages.config └── EverythingNet.Bench.csproj ├── EverythingNet.sln.DotSettings ├── LICENSE ├── appveyor.yml ├── README.md ├── EverythingNet.sln └── CODE_OF_CONDUCT.md /media/site_logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ju2pom/EverythingNet/HEAD/media/site_logo.gif -------------------------------------------------------------------------------- /media/site_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ju2pom/EverythingNet/HEAD/media/site_logo.png -------------------------------------------------------------------------------- /media/site_logo.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ju2pom/EverythingNet/HEAD/media/site_logo.xcf -------------------------------------------------------------------------------- /Everything/Everything.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ju2pom/EverythingNet/HEAD/Everything/Everything.dll -------------------------------------------------------------------------------- /Everything/Everything.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ju2pom/EverythingNet/HEAD/Everything/Everything.exe -------------------------------------------------------------------------------- /Everything/Everything32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ju2pom/EverythingNet/HEAD/Everything/Everything32.dll -------------------------------------------------------------------------------- /Everything/Everything64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ju2pom/EverythingNet/HEAD/Everything/Everything64.dll -------------------------------------------------------------------------------- /EverythingNet.Tests/TestData/sound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ju2pom/EverythingNet/HEAD/EverythingNet.Tests/TestData/sound.mp3 -------------------------------------------------------------------------------- /EverythingNet/Interfaces/ResultKind.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | public enum ResultKind 4 | { 5 | Both, 6 | FilesOnly, 7 | FoldersOnly 8 | } 9 | } -------------------------------------------------------------------------------- /EverythingNet/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | EverythingNet\.Tests/bin/ 3 | EverythingNet\.Tests/obj/ 4 | EverythingNet/bin/x64/ 5 | EverythingNet/obj/ 6 | EverythingNet\.Bench/bin/ 7 | EverythingNet\.Bench/obj/ 8 | 9 | packages/ 10 | 11 | \.vs/ 12 | 13 | *.user 14 | 15 | *.nupkg -------------------------------------------------------------------------------- /EverythingNet/Interfaces/IQueryGenerator.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | using System.Collections.Generic; 4 | 5 | internal interface IQueryGenerator 6 | { 7 | RequestFlags Flags { get; } 8 | 9 | IEnumerable GetQueryParts(); 10 | } 11 | } -------------------------------------------------------------------------------- /EverythingNet/Interfaces/IQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | using System.Collections.Generic; 4 | 5 | public interface IQueryable : IEnumerable 6 | { 7 | bool IsFast { get; } 8 | 9 | long Count { get; } 10 | 11 | IQuery And { get; } 12 | 13 | IQuery Or { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /EverythingNet.Bench/Program.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Bench 2 | { 3 | using System.Reflection; 4 | 5 | using BenchmarkDotNet.Running; 6 | 7 | internal class Program 8 | { 9 | private static void Main(string[] args) 10 | { 11 | BenchmarkSwitcher.FromAssembly(Assembly.GetCallingAssembly()).RunAll(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /EverythingNet/Interfaces/IMusicQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | public interface IMusicQueryable : IQueryable 4 | { 5 | IMusicQueryable Album(string album); 6 | 7 | IMusicQueryable Artist(string artist); 8 | 9 | IMusicQueryable Genre(string genre); 10 | 11 | IMusicQueryable Title(string title); 12 | 13 | // TODO: Add a way to nicely support constraints on track value (<, >, between) 14 | IMusicQueryable Track(int? track); 15 | 16 | IMusicQueryable Comment(string comment); 17 | } 18 | } -------------------------------------------------------------------------------- /EverythingNet/Interfaces/INameQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | using System.Collections.Generic; 4 | 5 | public interface INameQueryable : IQueryable 6 | { 7 | INameQueryable Contains(string pattern); 8 | 9 | INameQueryable StartWith(string pattern); 10 | 11 | INameQueryable EndWith(string pattern); 12 | 13 | INameQueryable Extension(string extension); 14 | 15 | INameQueryable Extensions(IEnumerable extensions); 16 | 17 | INameQueryable Extensions(params string[] extensions); 18 | } 19 | } -------------------------------------------------------------------------------- /EverythingNet/Interfaces/ISearchResult.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | using System; 4 | 5 | public interface ISearchResult 6 | { 7 | long Index { get; } 8 | 9 | bool IsFile { get; } 10 | 11 | string FullPath { get; } 12 | 13 | string Path { get; } 14 | 15 | string FileName { get; } 16 | 17 | long Size { get; } 18 | 19 | uint Attributes { get; } 20 | 21 | DateTime Created { get; } 22 | 23 | DateTime Modified { get; } 24 | 25 | DateTime Accessed { get; } 26 | 27 | DateTime Executed { get; } 28 | 29 | Exception LastException { get; } 30 | } 31 | } -------------------------------------------------------------------------------- /EverythingNet/Interfaces/IImageQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | public enum Bpp 4 | { 5 | Bpp1 = 1, 6 | Bpp8 = 8, 7 | Bpp16 = 16, 8 | Bpp24 = 24, 9 | Bpp32 = 32 10 | } 11 | 12 | /// 13 | /// Only jpg, png, gif and bmp file are supported with these queries 14 | /// 15 | public interface IImageQueryable : IQueryable 16 | { 17 | IImageQueryable Width(int width); 18 | 19 | IImageQueryable Height(int height); 20 | 21 | IImageQueryable Portrait(); 22 | 23 | IImageQueryable Landscape(); 24 | 25 | IImageQueryable BitDepth(Bpp bpp); 26 | } 27 | } -------------------------------------------------------------------------------- /EverythingNet/Interfaces/IFileQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | public interface IFileQueryable : IQueryable 4 | { 5 | IFileQueryable Roots(); 6 | 7 | IFileQueryable Parent(string parentFolder); 8 | 9 | IFileQueryable Audio(string search = null); 10 | 11 | IFileQueryable Zip(string search = null); 12 | 13 | IFileQueryable Video(string search = null); 14 | 15 | IFileQueryable Picture(string search = null); 16 | 17 | IFileQueryable Exe(string search = null); 18 | 19 | IFileQueryable Document(string search = null); 20 | 21 | IFileQueryable Duplicates(string search = null); 22 | } 23 | } -------------------------------------------------------------------------------- /EverythingNet/EverythingNet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Everything64.dll 6 | PreserveNewest 7 | 8 | 9 | Everything.exe 10 | PreserveNewest 11 | 12 | 13 | -------------------------------------------------------------------------------- /EverythingNet/Interfaces/IQuery.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | public interface IQuery 4 | { 5 | IQuery Not { get; } 6 | 7 | IQuery Files { get; } 8 | 9 | IQuery Folders { get; } 10 | 11 | IQuery NoSubFolder { get; } 12 | 13 | INameQueryable Name { get; } 14 | 15 | ISizeQueryable Size { get; } 16 | 17 | IDateQueryable CreationDate { get; } 18 | 19 | IDateQueryable ModificationDate { get; } 20 | 21 | IDateQueryable AccessDate { get; } 22 | 23 | IDateQueryable RunDate { get; } 24 | 25 | IMusicQueryable Music { get; } 26 | 27 | IFileQueryable File { get; } 28 | 29 | IImageQueryable Image { get; } 30 | 31 | IQueryable Queryable(IQueryable queryable); 32 | } 33 | } -------------------------------------------------------------------------------- /EverythingNet/Query/LogicalQuery.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System.Collections.Generic; 4 | 5 | using EverythingNet.Interfaces; 6 | 7 | internal class LogicalQuery : Query 8 | { 9 | private readonly string logicalOperator; 10 | 11 | public LogicalQuery(IEverythingInternal everything, IQueryGenerator parent, string logicalOperator) 12 | : base(everything, parent) 13 | { 14 | this.logicalOperator = logicalOperator; 15 | } 16 | 17 | public override IEnumerable GetQueryParts() 18 | { 19 | List query = new List(); 20 | 21 | query.AddRange(base.GetQueryParts()); 22 | query.Add(this.logicalOperator); 23 | 24 | return query; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /EverythingNet/Interfaces/ISizeQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | using EverythingNet.Query; 4 | 5 | public interface ISizeQueryable : IQueryable 6 | { 7 | ISizeQueryable Equal(int value); 8 | 9 | ISizeQueryable Equal(int value, SizeUnit u); 10 | 11 | ISizeQueryable Equal(Sizes size); 12 | 13 | ISizeQueryable GreaterThan(int value); 14 | 15 | ISizeQueryable GreaterThan(int value, SizeUnit u); 16 | 17 | ISizeQueryable GreaterOrEqualThan(int value); 18 | 19 | ISizeQueryable GreaterOrEqualThan(int value, SizeUnit u); 20 | 21 | ISizeQueryable LessThan(int value); 22 | 23 | ISizeQueryable LessThan(int value, SizeUnit u); 24 | 25 | ISizeQueryable LessOrEqualThan(int value); 26 | 27 | ISizeQueryable LessOrEqualThan(int value, SizeUnit u); 28 | 29 | ISizeQueryable Between(int min, int max); 30 | 31 | ISizeQueryable Between(int min, int max, SizeUnit u); 32 | 33 | ISizeQueryable Between(int min, SizeUnit umin, int max, SizeUnit umax); 34 | } 35 | } -------------------------------------------------------------------------------- /EverythingNet/EverythingNet.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EverythingNet 5 | 1.0.0 6 | EverythingNet 7 | ju2pom 8 | ju2pom 9 | https://github.com/ju2pom/EverythingNet 10 | false 11 | .NET library that wraps Everything Search excellent tool that allows to instantly search for files. 12 | Copyright © 2017 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /EverythingNet.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /EverythingNet/Interfaces/SortingKey.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | public enum SortingKey 4 | { 5 | None = 0, 6 | NameAscending = 1, 7 | NameDescending = 2, 8 | PathAscending = 3, 9 | PathDescending = 4, 10 | SizeAscending = 5, 11 | SizeDescending = 6, 12 | ExtensionAscending = 7, 13 | ExtensionDescending = 8, 14 | TypeNameAscending = 9, 15 | TypeNameDescending = 10, 16 | DateCreatedAscending = 11, 17 | DateCreatedDescending = 12, 18 | DateModifiedAscending = 13, 19 | DateModifiedDescending = 14, 20 | AttributesAscending = 15, 21 | AttributesDescending = 16, 22 | FileListFilenameAscending = 17, 23 | FileListFilenameDescending = 18, 24 | RunCountAscending = 19, 25 | RunCountDescending = 20, 26 | DateRecentlyChangedAscending = 21, 27 | DateRecentlyChangedDescending = 22, 28 | DateAccessedAscending = 23, 29 | DateAccessedDescending = 24, 30 | DateRunAscending = 25, 31 | DateRunDescending = 26, 32 | } 33 | } -------------------------------------------------------------------------------- /EverythingNet.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | D:\code\EverythingNet\ju2pom.DotSettings 3 | ..\ju2pom.DotSettings 4 | True 5 | True 6 | 1 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Julien Amsellem 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /EverythingNet.Tests/Init.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading; 3 | using EverythingNet.Core; 4 | using NUnit.Framework; 5 | 6 | namespace EverythingNet.Tests 7 | { 8 | [SetUpFixture] 9 | public class Init 10 | { 11 | private static int Timeout = 60 * 1000; // 1 min 12 | 13 | [OneTimeSetUp] 14 | public void RunBeforeAnyTests() 15 | { 16 | if (!EverythingState.IsStarted()) 17 | { 18 | EverythingState.StartService(true, EverythingState.StartMode.Service); 19 | } 20 | 21 | Stopwatch stopwatch = new Stopwatch(); 22 | stopwatch.Start(); 23 | 24 | while (!EverythingState.IsReady() && stopwatch.ElapsedMilliseconds < Timeout) 25 | { 26 | var lastError = EverythingState.GetLastError(); 27 | Assert.Warn($"Current Everything error code: {lastError}"); 28 | Thread.Sleep(200); 29 | } 30 | 31 | stopwatch.Stop(); 32 | 33 | if (stopwatch.ElapsedMilliseconds > Timeout) 34 | { 35 | Assert.Fail("Could not start Everything process"); 36 | } 37 | else 38 | { 39 | Assert.Warn($"Everything version: {EverythingState.GetVersion()}"); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /EverythingNet/Extensions/MacroSearch.cs: -------------------------------------------------------------------------------- 1 | using EverythingNet.Core; 2 | 3 | namespace EverythingNet.Extensions 4 | { 5 | public static class MacroSearch 6 | { 7 | public static IEverything Audio(this IEverything everything, string search = null) 8 | { 9 | return Macro(everything, "audio:", search); 10 | } 11 | 12 | public static IEverything Zip(this IEverything everything, string search = null) 13 | { 14 | return Macro(everything, "zip:", search); 15 | } 16 | 17 | public static IEverything Video(this IEverything everything, string search = null) 18 | { 19 | return Macro(everything, "video:", search); 20 | } 21 | 22 | public static IEverything Picture(this IEverything everything, string search = null) 23 | { 24 | return Macro(everything, "pic:", search); 25 | } 26 | 27 | public static IEverything Exe(this IEverything everything, string search = null) 28 | { 29 | return Macro(everything, "exe:", search); 30 | } 31 | 32 | public static IEverything Document(this IEverything everything, string search = null) 33 | { 34 | return Macro(everything, "doc:", search); 35 | } 36 | 37 | private static IEverything Macro(IEverything everything, string tag, string search) 38 | { 39 | everything.SearchText += tag + LogicSearch.QuoteIfNeeded(search); 40 | 41 | return everything; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /EverythingNet/Query/ImageQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System.Collections.Generic; 4 | 5 | using EverythingNet.Interfaces; 6 | 7 | internal class ImageQueryable : Queryable, IImageQueryable 8 | { 9 | private string pattern; 10 | 11 | public ImageQueryable(IEverythingInternal everything, IQueryGenerator parent) 12 | : base(everything, parent) 13 | { 14 | } 15 | 16 | public IImageQueryable Width(int width) 17 | { 18 | return this.Search($"width:{width}"); 19 | } 20 | 21 | public IImageQueryable Height(int height) 22 | { 23 | return this.Search($"height:{height}"); 24 | } 25 | 26 | public IImageQueryable Portrait() 27 | { 28 | return this.Search("orienation:portrait"); 29 | } 30 | 31 | public IImageQueryable Landscape() 32 | { 33 | return this.Search("orienation:landscape"); 34 | } 35 | 36 | public IImageQueryable BitDepth(Bpp bpp) 37 | { 38 | return this.Search($"bitdepth:{(int)bpp}"); 39 | } 40 | 41 | public override IEnumerable GetQueryParts() 42 | { 43 | foreach (var queryPart in base.GetQueryParts()) 44 | { 45 | yield return queryPart; 46 | } 47 | 48 | yield return this.pattern; 49 | } 50 | 51 | private IImageQueryable Search(string search) 52 | { 53 | this.pattern = search; 54 | 55 | return this; 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /EverythingNet/Extensions/MucisSearch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using EverythingNet.Core; 3 | 4 | namespace EverythingNet.Extensions 5 | { 6 | public static class MucisSearch 7 | { 8 | public static IEverything Album(this IEverything everything, string album = null) 9 | { 10 | return Search(everything, "album:", album); 11 | } 12 | 13 | public static IEverything Artist(this IEverything everything, string artist = null) 14 | { 15 | return Search(everything, "artist:", artist); 16 | } 17 | 18 | public static IEverything Genre(this IEverything everything, string genre = null) 19 | { 20 | return Search(everything, "genre:", genre); 21 | } 22 | 23 | public static IEverything Title(this IEverything everything, string title = null) 24 | { 25 | return Search(everything, "title:", title); 26 | } 27 | 28 | public static IEverything Track(this IEverything everything, int track = -1) 29 | { 30 | return Search(everything, "track:", track >= 0 ? $"{track}" : String.Empty); 31 | } 32 | 33 | public static IEverything Comment(this IEverything everything, string comment = null) 34 | { 35 | return Search(everything, "comment:", comment); 36 | } 37 | 38 | private static IEverything Search(IEverything everything, string tag, string search) 39 | { 40 | everything.SearchText += tag + LogicSearch.QuoteIfNeeded(search); 41 | 42 | return everything; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /EverythingNet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("ClassLibrary1")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("ClassLibrary1")] 12 | [assembly: AssemblyCopyright("Copyright © 2017")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("c6cc7352-f58b-4274-b629-a15a7f3c69cd")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /EverythingNet.Bench/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EverythingNet.Bench")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("EverythingNet.Bench")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d077c127-1161-41f5-bc74-fbdcce294812")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /EverythingNet.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EverythingNet.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("EverythingNet.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("47039d9a-1f54-49d3-b19c-274840eefde6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /EverythingNet.Bench/CombinedQueryBench.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Bench 2 | { 3 | using BenchmarkDotNet.Attributes; 4 | using BenchmarkDotNet.Attributes.Jobs; 5 | using BenchmarkDotNet.Engines; 6 | 7 | using EverythingNet.Core; 8 | using EverythingNet.Interfaces; 9 | using EverythingNet.Query; 10 | 11 | [SimpleJob(RunStrategy.ColdStart, launchCount: 2, warmupCount: 1, targetCount: 4, invocationCount: 8, id: "FastAndDirtyJob")] 12 | public class CombinedQueryBench 13 | { 14 | [Benchmark] 15 | public long NameAndDateModified() 16 | { 17 | var queryable = new Everything() 18 | .Search() 19 | .Name.Contains("windows") 20 | .And 21 | .ModificationDate.Equal(Dates.Today); 22 | 23 | return queryable.Count; 24 | } 25 | 26 | [Benchmark] 27 | public long NameAndSize() 28 | { 29 | var queryable = new Everything() 30 | .Search() 31 | .Name.Contains("windows") 32 | .And 33 | .Size.LessThan(1, SizeUnit.Mb); 34 | 35 | return queryable.Count; 36 | } 37 | 38 | [Benchmark] 39 | public long QueryAndQuery() 40 | { 41 | var everything = new Everything(); 42 | var queryable1 = everything 43 | .Search() 44 | .Name.Contains("windows"); 45 | 46 | var queryable2 = everything 47 | .Search() 48 | .Size.LessThan(1, SizeUnit.Mb); 49 | 50 | return everything 51 | .Search() 52 | .Queryable(queryable1) 53 | .And 54 | .Queryable(queryable2) 55 | .Count; 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: 2 | - Visual Studio 2017 3 | environment: 4 | COVERALLS_REPO_TOKEN: 5 | secure: biV61oNW1Heo5wiOkUWFLyMF8lk+O50x+qH98xrSnAmS7OzwDdAFa521/qiAq4Cz 6 | # APPVEYOR_RDP_PASSWORD: 7 | # secure: ahdRD+rzw7Hi5/NXzdZ/9aJOMPlZlKFmz5AkWIyMna8= 8 | 9 | # init: 10 | # - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) 11 | # on_finish: 12 | # - ps: $blockRdp = $true;iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) 13 | version: 1.0.{build} 14 | configuration: Release 15 | platform: x64 16 | 17 | before_build: 18 | - cmd: nuget restore 19 | 20 | build: 21 | verbosity: minimal 22 | project: EverythingNet.sln 23 | 24 | after_test: 25 | - cmd: packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user -filter:"+[*]*" -target:"packages\NUnit.ConsoleRunner.3.6.1\tools\nunit3-console.exe" -targetargs:"/domain:single EverythingNet.Tests/bin/x64/release/EverythingNet.Tests.dll" -output:coverage.xml 26 | - cmd: packages\coveralls.io.1.3.4\tools\coveralls.net.exe --opencover coverage.xml 27 | - cmd: EverythingNet.Bench\bin\Release\EverythingNet.Bench.exe 28 | 29 | after_build: 30 | - nuget pack EverythingNet\EverythingNet.nuspec -Version %appveyor_build_version% 31 | 32 | artifacts: 33 | - path: EverythingNet*.nupkg 34 | name: EverythingNet nuget package 35 | type: NuGetPackage 36 | 37 | # deploy: 38 | # provider: NuGet 39 | # api_key: 40 | # secure: yJDVT5OnmUa9yNyNi3kDiYilytCOalBDZ5Pvz0jqmRc40WhBi8kHwNIvVcv5YzRU -------------------------------------------------------------------------------- /EverythingNet/Extensions/SizeSearch.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using EverythingNet.Core; 3 | 4 | namespace EverythingNet.Extensions 5 | { 6 | public static class SizeSearch 7 | { 8 | public enum SizeStandard 9 | { 10 | Empty, 11 | Unknown, 12 | Tiny, 13 | Small, 14 | Medium, 15 | Large, 16 | Huge, 17 | Gigantic, 18 | } 19 | 20 | public enum SizeUnit 21 | { 22 | Kb, 23 | Mb, 24 | Gb, 25 | } 26 | 27 | public static IEverything Size(this IEverything everything) 28 | { 29 | return Size(everything, "size:"); 30 | } 31 | 32 | public static IEverything Size(this IEverything everything, int size) 33 | { 34 | return Size(everything, $"size:{size}"); 35 | } 36 | 37 | public static IEverything Kb(this IEverything everything) 38 | { 39 | return everything.Unit(SizeUnit.Kb); 40 | } 41 | 42 | public static IEverything Mb(this IEverything everything) 43 | { 44 | return everything.Unit(SizeUnit.Mb); 45 | } 46 | 47 | public static IEverything Gb(this IEverything everything) 48 | { 49 | return everything.Unit(SizeUnit.Gb); 50 | } 51 | 52 | public static IEverything Unit(this IEverything everything, SizeUnit unit) 53 | { 54 | return Size(everything, unit.ToString().ToLower()); 55 | } 56 | 57 | public static IEverything Standard(this IEverything everything, SizeStandard size) 58 | { 59 | return Size(everything, size.ToString().ToLower()); 60 | } 61 | 62 | private static IEverything Size(IEverything everything, string text) 63 | { 64 | everything.SearchText += text; 65 | 66 | return everything; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /EverythingNet.Tests/LogicalQueryTests.cs: -------------------------------------------------------------------------------- 1 | using EverythingNet.Core; 2 | using NUnit.Framework; 3 | 4 | namespace EverythingNet.Tests 5 | { 6 | [TestFixture] 7 | public class LogicalQueryTests 8 | { 9 | private Everything everything; 10 | 11 | [SetUp] 12 | public void Setup() 13 | { 14 | this.everything = new Everything(); 15 | } 16 | 17 | [TearDown] 18 | public void TearDown() 19 | { 20 | this.everything.Dispose(); 21 | } 22 | 23 | [Test] 24 | public void And() 25 | { 26 | var queryable = this.everything 27 | .Search() 28 | .Name 29 | .StartWith("prefix") 30 | .And 31 | .Name 32 | .EndWith("suffix"); 33 | 34 | Assert.That(queryable.ToString(), Is.EqualTo("startwith:prefix endwith:suffix")); 35 | } 36 | 37 | [Test] 38 | public void AndQuery() 39 | { 40 | var sizeQuery = this.everything 41 | .Search() 42 | .Size 43 | .LessOrEqualThan(100); 44 | var queryable = this.everything 45 | .Search() 46 | .Name 47 | .StartWith("prefix") 48 | .And 49 | .Queryable(sizeQuery); 50 | 51 | Assert.That(queryable.ToString(), Is.EqualTo("startwith:prefix size:<=100kb")); 52 | } 53 | 54 | 55 | [Test] 56 | public void FilesQuery() 57 | { 58 | var filesQuery = this.everything 59 | .Search() 60 | .Files 61 | .Name; 62 | 63 | Assert.That(filesQuery.ToString(), Is.EqualTo("files:")); 64 | } 65 | 66 | 67 | [Test] 68 | public void FoldersQuery() 69 | { 70 | var foldersQuery = this.everything 71 | .Search() 72 | .Folders 73 | .Name; 74 | 75 | Assert.That(foldersQuery.ToString(), Is.EqualTo("folders:")); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /EverythingNet/Interfaces/IEverything.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using EverythingNet.Core; 7 | 8 | public enum ErrorCode 9 | { 10 | Ok = 0, 11 | Memory, 12 | Ipc, 13 | RegisterClassEX, 14 | CreateWindow, 15 | CreateThread, 16 | InvalidIndex, 17 | Invalidcall 18 | } 19 | 20 | [Flags] 21 | public enum RequestFlags 22 | { 23 | EVERYTHING_REQUEST_FILE_NAME = 0x00000001, 24 | EVERYTHING_REQUEST_PATH = 0x00000002, 25 | EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME = 0x00000004, 26 | EVERYTHING_REQUEST_EXTENSION = 0x00000008, 27 | EVERYTHING_REQUEST_SIZE = 0x00000010, 28 | EVERYTHING_REQUEST_DATE_CREATED = 0x00000020, 29 | EVERYTHING_REQUEST_DATE_MODIFIED = 0x00000040, 30 | EVERYTHING_REQUEST_DATE_ACCESSED = 0x00000080, 31 | EVERYTHING_REQUEST_ATTRIBUTES = 0x00000100, 32 | EVERYTHING_REQUEST_FILE_LIST_FILE_NAME = 0x00000200, 33 | EVERYTHING_REQUEST_RUN_COUNT = 0x00000400, 34 | EVERYTHING_REQUEST_DATE_RUN = 0x00000800, 35 | EVERYTHING_REQUEST_DATE_RECENTLY_CHANGED = 0x00001000, 36 | EVERYTHING_REQUEST_HIGHLIGHTED_FILE_NAME = 0x00002000, 37 | EVERYTHING_REQUEST_HIGHLIGHTED_PATH = 0x00004000, 38 | EVERYTHING_REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = 0x00008000 39 | } 40 | 41 | public interface IEverything 42 | { 43 | ResultKind ResulKind { get; set; } 44 | 45 | bool MatchCase { get; set; } 46 | 47 | bool MatchPath { get; set; } 48 | 49 | bool MatchWholeWord { get; set; } 50 | 51 | SortingKey SortKey { get; set; } 52 | 53 | IQuery Search(); 54 | 55 | void Reset(); 56 | } 57 | 58 | internal interface IEverythingInternal : IEverything 59 | { 60 | long Count { get; } 61 | 62 | IEnumerable SendSearch(string searchPattern, RequestFlags flags); 63 | } 64 | } -------------------------------------------------------------------------------- /EverythingNet/Interfaces/IDateQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Interfaces 2 | { 3 | using System; 4 | 5 | public enum Dates 6 | { 7 | Today, 8 | Yesterday, 9 | ThisWeek, 10 | ThisMonth, 11 | ThisYear, 12 | ThisSunday, 13 | ThisMonday, 14 | ThisTuesday, 15 | ThisWednesday, 16 | ThisThursday, 17 | ThisFriday, 18 | ThisSaturday, 19 | ThisJanuary, 20 | ThisFebuary, 21 | ThisMarch, 22 | ThisApril, 23 | ThisMay, 24 | ThisJune, 25 | ThisJuly, 26 | ThisAugust, 27 | ThisSeptember, 28 | ThisOctober, 29 | ThisNovember, 30 | ThisDecember, 31 | LastSunday, 32 | LastMonday, 33 | LastTuesday, 34 | LastWednesday, 35 | LastThursday, 36 | LastFriday, 37 | LastSaturday, 38 | LastWeek, 39 | LastMonth, 40 | LastYear, 41 | LastJanuary, 42 | LastFebuary, 43 | LastMarch, 44 | LastApril, 45 | LastMay, 46 | LastJune, 47 | LastJuly, 48 | LastAugust, 49 | LastSeptember, 50 | LastOctober, 51 | LastNovember, 52 | LastDecember, 53 | NextYear, 54 | NextMonth, 55 | NextWeek 56 | } 57 | 58 | public enum CountableDates 59 | { 60 | Seconds, 61 | Minutes, 62 | Hours, 63 | Weeks, 64 | Months, 65 | Years 66 | } 67 | 68 | public interface IDateQueryable : IQueryable 69 | { 70 | IDateQueryable Equal(DateTime date); 71 | 72 | IDateQueryable Equal(Dates date); 73 | 74 | IDateQueryable Before(DateTime date); 75 | 76 | IDateQueryable Before(Dates date); 77 | 78 | IDateQueryable After(DateTime date); 79 | 80 | IDateQueryable After(Dates date); 81 | 82 | IDateQueryable Between(DateTime from, DateTime to); 83 | 84 | IDateQueryable Between(Dates from, Dates to); 85 | 86 | IDateQueryable Last(int count, CountableDates date); 87 | 88 | IDateQueryable Next(int count, CountableDates date); 89 | } 90 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build status](https://img.shields.io/appveyor/ci/ju2pom/everythingnet/master.svg?style=flat)](https://ci.appveyor.com/project/ju2pom/everythingnet/branch/master) 2 | [![Coverage Status](https://coveralls.io/repos/github/ju2pom/EverythingNet/badge.svg?branch=master)](https://coveralls.io/github/ju2pom/EverythingNet?branch=master) 3 | [![NuGet](https://img.shields.io/nuget/v/EverythingNet.svg?style=flat)](https://www.nuget.org/packages/EverythingNet/) 4 | 5 | # EverythingNet ![](media/site_logo.gif) 6 | 7 | ## Check demo app 8 | 9 | https://github.com/ju2pom/EverythingNetDemo 10 | 11 | ## What 12 | 13 | EverythingNet is a C# library that wraps the great library from voidtools named Everything. This library lets you search for files and folders incredibly fast. For more information jump to the [official page](https://www.voidtools.com/) 14 | 15 | EverythingNet provides a simple .NET API that wraps aforementioned library (which is coded in C). It doesn't rely on Windows Search at all but on a specific service which is much faster and lighter. 16 | 17 | EverythingNet exposes a fluent API that ease access to specific search functions. 18 | 19 | ## Features 20 | 21 | The fluent API provides the following set of features: 22 | - [x] thread safety 23 | - [x] search for files only or folders only or both 24 | - [x] name contains/start with/end with 25 | - [x] search by extension or list of extensions 26 | - [x] logical operators (Not, And, Or) 27 | - [x] size search criteria 28 | - [x] picture properties search criteria (format, dimensions) 29 | - [x] audio search criteria (ID3 Tags) 30 | - [x] dates search criteria (creation, modification, access, execution) 31 | - [ ] file content (maybe later) 32 | 33 | ## How 34 | 35 | The library exposes a fluent API that ease access to specific search functions. 36 | Here is a very simple example: 37 | 38 | ```csharp 39 | IEverything everything = new Everything(); 40 | var results = everything.Search().Name.Contains("temp"); 41 | ``` 42 | 43 | ## Wiki 44 | [Wiki](https://github.com/ju2pom/EverythingNet/wiki) 45 | -------------------------------------------------------------------------------- /EverythingNet/Query/Query.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | using EverythingNet.Interfaces; 7 | 8 | using IQueryable = Interfaces.IQueryable; 9 | 10 | internal class Query : IQuery, IQueryGenerator 11 | { 12 | private readonly IEverythingInternal everything; 13 | private readonly IQueryGenerator parent; 14 | 15 | public Query(IEverythingInternal everything, IQueryGenerator parent = null) 16 | { 17 | this.everything = everything; 18 | this.parent = parent; 19 | } 20 | 21 | public IQuery Not => new LogicalQuery(this.everything, this, "!"); 22 | 23 | public IQuery Files => new LogicalQuery(this.everything, this, "files:"); 24 | 25 | public IQuery Folders => new LogicalQuery(this.everything, this, "folders:"); 26 | 27 | public IQuery NoSubFolder => new LogicalQuery(this.everything, this, "nosubfolders:"); 28 | 29 | public INameQueryable Name => new NameQueryable(this.everything, this); 30 | 31 | public ISizeQueryable Size => new SizeQueryable(this.everything, this); 32 | 33 | public IDateQueryable CreationDate => new DateQueryable(this.everything, this, "dc:"); 34 | 35 | public IDateQueryable ModificationDate => new DateQueryable(this.everything, this, "dm:"); 36 | 37 | public IDateQueryable AccessDate => new DateQueryable(this.everything, this, "da:"); 38 | 39 | public IDateQueryable RunDate => new DateQueryable(this.everything, this, "dr:"); 40 | 41 | public IMusicQueryable Music => new MusicQueryable(this.everything, this); 42 | 43 | public IFileQueryable File => new FileQueryable(this.everything, this); 44 | 45 | public IImageQueryable Image => new ImageQueryable(this.everything, this); 46 | 47 | public IQueryable Queryable(IQueryable queryable) 48 | { 49 | ((Queryable)queryable).SetParent(this); 50 | 51 | return queryable; 52 | } 53 | 54 | public RequestFlags Flags => this.parent?.Flags ?? 0; 55 | 56 | public virtual IEnumerable GetQueryParts() 57 | { 58 | return this.parent?.GetQueryParts() ?? Enumerable.Empty(); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /EverythingNet/Core/EverythingState.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Core 2 | { 3 | using System; 4 | using System.Diagnostics; 5 | using System.IO; 6 | using System.Reflection; 7 | 8 | using EverythingNet.Interfaces; 9 | 10 | public static class EverythingState 11 | { 12 | public enum StartMode 13 | { 14 | Install, 15 | Service 16 | } 17 | 18 | public static bool IsStarted() 19 | { 20 | Version version = GetVersion(); 21 | 22 | return version.Major > 0; 23 | } 24 | 25 | public static bool StartService(bool admin, StartMode mode) 26 | { 27 | if (!IsStarted()) 28 | { 29 | string option = admin ? "-admin" : string.Empty; 30 | 31 | switch (mode) 32 | { 33 | case StartMode.Install: 34 | option += " -install-service"; 35 | break; 36 | case StartMode.Service: 37 | option += " -startup"; 38 | break; 39 | } 40 | 41 | StartProcess(option); 42 | 43 | return IsStarted(); 44 | } 45 | 46 | return true; 47 | } 48 | 49 | public static bool IsReady() 50 | { 51 | return EverythingWrapper.Everything_IsDBLoaded(); 52 | } 53 | 54 | public static Version GetVersion() 55 | { 56 | UInt32 major = EverythingWrapper.Everything_GetMajorVersion(); 57 | UInt32 minor = EverythingWrapper.Everything_GetMinorVersion(); 58 | UInt32 build = EverythingWrapper.Everything_GetBuildNumber(); 59 | UInt32 revision = EverythingWrapper.Everything_GetRevision(); 60 | 61 | return new Version(Convert.ToInt32(major), Convert.ToInt32(minor), Convert.ToInt32(build), Convert.ToInt32(revision)); 62 | } 63 | 64 | public static ErrorCode GetLastError() 65 | { 66 | return (ErrorCode)EverythingWrapper.Everything_GetLastError(); 67 | } 68 | 69 | private static void StartProcess(string options) 70 | { 71 | string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 72 | string exePath = Path.GetFullPath(Path.Combine(path, @"Everything.exe")); 73 | 74 | Process.Start(exePath, options); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /EverythingNet.Bench/SimpleQueryBench.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Bench 2 | { 3 | using BenchmarkDotNet.Attributes; 4 | using BenchmarkDotNet.Attributes.Jobs; 5 | using BenchmarkDotNet.Engines; 6 | 7 | using EverythingNet.Core; 8 | using EverythingNet.Interfaces; 9 | using EverythingNet.Query; 10 | 11 | [SimpleJob(RunStrategy.ColdStart, launchCount: 2, warmupCount: 1, targetCount: 4, invocationCount: 8, id: "FastAndDirtyJob")] 12 | public class SimpleQueryBench 13 | { 14 | [Benchmark] 15 | public long NameContains() 16 | { 17 | var queryable = new Everything() 18 | .Search() 19 | .Name.Contains("windows"); 20 | 21 | return queryable.Count; 22 | } 23 | 24 | [Benchmark] 25 | public long NameStartWith() 26 | { 27 | var queryable = new Everything() 28 | .Search() 29 | .Name.StartWith("user"); 30 | 31 | return queryable.Count; 32 | } 33 | 34 | [Benchmark] 35 | public long DateModified() 36 | { 37 | var queryable = new Everything() 38 | .Search() 39 | .ModificationDate.Equal(Dates.Today); 40 | 41 | return queryable.Count; 42 | } 43 | 44 | /*[Benchmark] 45 | public long DateCreated() 46 | { 47 | var queryable = new Everything() 48 | .Search() 49 | .CreationDate.Equal(Dates.Today); 50 | 51 | return queryable.Count; 52 | } 53 | 54 | [Benchmark] 55 | public long DateAccessed() 56 | { 57 | var queryable = new Everything() 58 | .Search() 59 | .AccessDate.Equal(Dates.Today); 60 | 61 | return queryable.Count; 62 | } 63 | */ 64 | 65 | [Benchmark] 66 | public long DateRun() 67 | { 68 | var queryable = new Everything() 69 | .Search() 70 | .RunDate.Equal(Dates.Today); 71 | 72 | return queryable.Count; 73 | } 74 | 75 | [Benchmark] 76 | public long SmallSize() 77 | { 78 | var queryable = new Everything() 79 | .Search() 80 | .Size.Equal(Sizes.Small); 81 | 82 | return queryable.Count; 83 | } 84 | 85 | [Benchmark] 86 | public long GreaterThan1MoSize() 87 | { 88 | var queryable = new Everything() 89 | .Search() 90 | .Size.GreaterThan(1, SizeUnit.Mb); 91 | 92 | return queryable.Count; 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /EverythingNet/Extensions/LogicSearch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using EverythingNet.Core; 4 | 5 | namespace EverythingNet.Extensions 6 | { 7 | public static class LogicSearch 8 | { 9 | public static IEverything Is(this IEverything everything, string value) 10 | { 11 | everything.SearchText += QuoteIfNeeded(value); 12 | 13 | return everything; 14 | } 15 | 16 | public static IEverything Is(this IEverything everything, object value) 17 | { 18 | everything.SearchText += QuoteIfNeeded(value.ToString()); 19 | 20 | return everything; 21 | } 22 | 23 | public static IEverything GreaterThan(this IEverything everything, int value) 24 | { 25 | everything.SearchText += $">{value}"; 26 | 27 | return everything; 28 | } 29 | 30 | public static IEverything GreaterOrEqualThan(this IEverything everything, int value) 31 | { 32 | everything.SearchText += $">={value}"; 33 | 34 | return everything; 35 | } 36 | 37 | public static IEverything LessThan(this IEverything everything, int value) 38 | { 39 | everything.SearchText += $"<{value}"; 40 | 41 | return everything; 42 | } 43 | 44 | public static IEverything LessOrEqualThan(this IEverything everything, int value) 45 | { 46 | everything.SearchText += $"<={value}"; 47 | 48 | return everything; 49 | } 50 | 51 | public static IEverything Or(this IEverything everything) 52 | { 53 | everything.SearchText += "|"; 54 | 55 | return everything; 56 | } 57 | 58 | public static IEverything And(this IEverything everything) 59 | { 60 | everything.SearchText += " "; 61 | 62 | return everything; 63 | } 64 | 65 | public static IEverything Not(this IEverything everything) 66 | { 67 | everything.SearchText += "!"; 68 | 69 | return everything; 70 | } 71 | 72 | public static IEverything Between(this IEverything everything, int min, int max, string unit = "") 73 | { 74 | everything.SearchText += $"{min}{unit}-{max}{unit}"; 75 | 76 | return everything; 77 | } 78 | 79 | public static IEverything Between(this IEverything everything, int min, int max, Enum unit) 80 | { 81 | string u = unit.ToString().ToLower(); 82 | 83 | everything.SearchText += $"{min}{u}-{max}{u}"; 84 | 85 | return everything; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /EverythingNet.Bench/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /EverythingNet/Query/Queryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | using EverythingNet.Interfaces; 8 | 9 | using IQueryable = Interfaces.IQueryable; 10 | 11 | internal abstract class Queryable : IQueryable, IQueryGenerator 12 | { 13 | private readonly IEverythingInternal everything; 14 | private IQueryGenerator parent; 15 | private IEnumerable results; 16 | 17 | protected Queryable(IEverythingInternal everything, IQueryGenerator parent) 18 | { 19 | this.everything = everything; 20 | this.parent = parent; 21 | this.IsFast = true; 22 | } 23 | 24 | public bool IsFast { get; protected set; } 25 | 26 | public long Count 27 | { 28 | get 29 | { 30 | this.ExecuteIfNeeded(); 31 | 32 | return this.everything.Count; 33 | } 34 | } 35 | 36 | public IQuery And => new LogicalQuery(this.everything, this, " "); 37 | 38 | public IQuery Or => new LogicalQuery(this.everything, this, "|"); 39 | 40 | public RequestFlags Flags { get; protected set; } 41 | 42 | public override string ToString() 43 | { 44 | return string.Join("", this.GetQueryParts()); 45 | } 46 | 47 | public IEnumerator GetEnumerator() 48 | { 49 | this.ExecuteIfNeeded(); 50 | 51 | return this.results.GetEnumerator(); 52 | } 53 | 54 | public virtual IEnumerable GetQueryParts() 55 | { 56 | return this.parent?.GetQueryParts() ?? Enumerable.Empty(); 57 | } 58 | 59 | protected string QuoteIfNeeded(string text) 60 | { 61 | if (text == null) 62 | { 63 | return string.Empty; 64 | } 65 | 66 | if (text.Contains(" ") && text.First() != '\"' && text.Last() != '\"') 67 | { 68 | return $"\"{text}\""; 69 | } 70 | 71 | return text; 72 | } 73 | 74 | internal void SetParent(IQueryGenerator onTheFlyparent) 75 | { 76 | this.parent = onTheFlyparent; 77 | } 78 | 79 | IEnumerator IEnumerable.GetEnumerator() 80 | { 81 | return this.GetEnumerator(); 82 | } 83 | 84 | private void ExecuteIfNeeded() 85 | { 86 | if (this.results == null) 87 | { 88 | this.results = this.everything.SendSearch(string.Join("", this.GetQueryParts()), this.parent.Flags|this.Flags); 89 | } 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /EverythingNet/Query/MusicQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System.Collections.Generic; 4 | 5 | using EverythingNet.Interfaces; 6 | 7 | internal class MusicQueryable : Queryable, IMusicQueryable 8 | { 9 | private string artistPattern; 10 | private string genrePattern; 11 | private string titlePattern; 12 | private int? trackNumber; 13 | private string commentPattern; 14 | private string albumPattern; 15 | 16 | public MusicQueryable(IEverythingInternal everything, IQueryGenerator parent) 17 | : base(everything, parent) 18 | { 19 | } 20 | 21 | public IMusicQueryable Album(string album) 22 | { 23 | this.albumPattern = this.QuoteIfNeeded(album); 24 | 25 | return this; 26 | } 27 | 28 | public IMusicQueryable Artist(string artist) 29 | { 30 | this.artistPattern = this.QuoteIfNeeded(artist); 31 | 32 | return this; 33 | } 34 | 35 | public IMusicQueryable Genre(string genre) 36 | { 37 | this.genrePattern = this.QuoteIfNeeded(genre); 38 | 39 | return this; 40 | } 41 | 42 | public IMusicQueryable Title(string title) 43 | { 44 | this.titlePattern = this.QuoteIfNeeded(title); 45 | 46 | return this; 47 | } 48 | 49 | public IMusicQueryable Track(int? track) 50 | { 51 | this.trackNumber = track; 52 | 53 | return this; 54 | } 55 | 56 | public IMusicQueryable Comment(string comment) 57 | { 58 | if (!string.IsNullOrEmpty(comment)) 59 | { 60 | this.commentPattern = this.QuoteIfNeeded(comment); 61 | } 62 | 63 | return this; 64 | } 65 | 66 | public override IEnumerable GetQueryParts() 67 | { 68 | foreach (var queryPart in base.GetQueryParts()) 69 | { 70 | yield return queryPart; 71 | } 72 | 73 | if (!string.IsNullOrEmpty(this.albumPattern)) 74 | { 75 | yield return $"album:{this.albumPattern}"; 76 | } 77 | 78 | if (!string.IsNullOrEmpty(this.artistPattern)) 79 | { 80 | yield return $"artist:{this.artistPattern}"; 81 | } 82 | 83 | if (!string.IsNullOrEmpty(this.genrePattern)) 84 | { 85 | yield return $"genre:{this.genrePattern}"; 86 | } 87 | 88 | if (!string.IsNullOrEmpty(this.titlePattern)) 89 | { 90 | yield return $"title:{this.titlePattern}"; 91 | } 92 | 93 | if (!string.IsNullOrEmpty(this.commentPattern)) 94 | { 95 | yield return $"comment:{this.commentPattern}"; 96 | } 97 | 98 | if (this.trackNumber.HasValue) 99 | { 100 | yield return $"track:{this.trackNumber}"; 101 | } 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /EverythingNet.Tests/MusicSearchTests.cs: -------------------------------------------------------------------------------- 1 | using EverythingNet.Core; 2 | using NUnit.Framework; 3 | 4 | namespace EverythingNet.Tests 5 | { 6 | [TestFixture] 7 | public class MusicSearchTests 8 | { 9 | private Everything everything; 10 | 11 | [SetUp] 12 | public void Setup() 13 | { 14 | this.everything = new Everything(); 15 | } 16 | 17 | [TearDown] 18 | public void TearDown() 19 | { 20 | this.everything.Dispose(); 21 | } 22 | 23 | [TestCase("The Wall", ExpectedResult = "album:\"The Wall\"")] 24 | public string Album(string album) 25 | { 26 | var queryable = this.everything 27 | .Search() 28 | .Music 29 | .Album(album); 30 | 31 | return queryable.ToString(); 32 | } 33 | 34 | [TestCase(null)] 35 | [TestCase("")] 36 | public void Album_Null(string album) 37 | { 38 | Assert.That(() => this.everything.Search().Music.Album(album).ToString(), Is.Empty); 39 | } 40 | 41 | 42 | [TestCase("Pink Floyed", ExpectedResult = "artist:\"Pink Floyed\"")] 43 | public string Artist(string artist) 44 | { 45 | var queryable = this.everything.Search().Music.Artist(artist); 46 | 47 | return queryable.ToString(); 48 | } 49 | 50 | 51 | [TestCase(null)] 52 | [TestCase("")] 53 | public void Artist_Null(string artist) 54 | { 55 | Assert.That(() => this.everything.Search().Music.Artist(artist).ToString(), Is.Empty); 56 | } 57 | 58 | [TestCase(0, ExpectedResult = "track:0")] 59 | [TestCase(2, ExpectedResult = "track:2")] 60 | public string Track(int? track) 61 | { 62 | var queryable = this.everything.Search().Music.Track(track); 63 | 64 | return queryable.ToString(); 65 | } 66 | 67 | 68 | [TestCase("great music", ExpectedResult = "comment:\"great music\"")] 69 | public string Comment(string comment) 70 | { 71 | var queryable = this.everything.Search().Music.Comment(comment); 72 | 73 | return queryable.ToString(); 74 | } 75 | 76 | [TestCase("Intro", ExpectedResult = "title:Intro")] 77 | public string Title(string title) 78 | { 79 | var queryable = this.everything.Search().Music.Title(title); 80 | 81 | return queryable.ToString(); 82 | } 83 | 84 | [TestCase("Rock", ExpectedResult = "genre:Rock")] 85 | public string Genre(string genre) 86 | { 87 | var queryable = this.everything.Search().Music.Genre(genre); 88 | 89 | return queryable.ToString(); 90 | } 91 | 92 | 93 | [Test] 94 | public void AcceptanceTest() 95 | { 96 | var queryable = new Everything() 97 | .Search() 98 | .Music.Genre("Bird"); 99 | 100 | Assert.That(queryable.Count, Is.GreaterThan(0)); 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /EverythingNet.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.16 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EverythingNet", "EverythingNet\EverythingNet.csproj", "{C6CC7352-F58B-4274-B629-A15A7F3C69CD}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EverythingNet.Tests", "EverythingNet.Tests\EverythingNet.Tests.csproj", "{47039D9A-1F54-49D3-B19C-274840EEFDE6}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EverythingNet.Bench", "EverythingNet.Bench\EverythingNet.Bench.csproj", "{D077C127-1161-41F5-BC74-FBDCCE294812}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|x64 = Debug|x64 16 | Release|Any CPU = Release|Any CPU 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {C6CC7352-F58B-4274-B629-A15A7F3C69CD}.Debug|Any CPU.ActiveCfg = Debug|x64 21 | {C6CC7352-F58B-4274-B629-A15A7F3C69CD}.Debug|x64.ActiveCfg = Debug|x64 22 | {C6CC7352-F58B-4274-B629-A15A7F3C69CD}.Debug|x64.Build.0 = Debug|x64 23 | {C6CC7352-F58B-4274-B629-A15A7F3C69CD}.Release|Any CPU.ActiveCfg = Release|x64 24 | {C6CC7352-F58B-4274-B629-A15A7F3C69CD}.Release|x64.ActiveCfg = Release|x64 25 | {C6CC7352-F58B-4274-B629-A15A7F3C69CD}.Release|x64.Build.0 = Release|x64 26 | {47039D9A-1F54-49D3-B19C-274840EEFDE6}.Debug|Any CPU.ActiveCfg = Debug|x64 27 | {47039D9A-1F54-49D3-B19C-274840EEFDE6}.Debug|x64.ActiveCfg = Debug|x64 28 | {47039D9A-1F54-49D3-B19C-274840EEFDE6}.Debug|x64.Build.0 = Debug|x64 29 | {47039D9A-1F54-49D3-B19C-274840EEFDE6}.Release|Any CPU.ActiveCfg = Release|x64 30 | {47039D9A-1F54-49D3-B19C-274840EEFDE6}.Release|x64.ActiveCfg = Release|x64 31 | {47039D9A-1F54-49D3-B19C-274840EEFDE6}.Release|x64.Build.0 = Release|x64 32 | {D077C127-1161-41F5-BC74-FBDCCE294812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {D077C127-1161-41F5-BC74-FBDCCE294812}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {D077C127-1161-41F5-BC74-FBDCCE294812}.Debug|x64.ActiveCfg = Debug|Any CPU 35 | {D077C127-1161-41F5-BC74-FBDCCE294812}.Debug|x64.Build.0 = Debug|Any CPU 36 | {D077C127-1161-41F5-BC74-FBDCCE294812}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {D077C127-1161-41F5-BC74-FBDCCE294812}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {D077C127-1161-41F5-BC74-FBDCCE294812}.Release|x64.ActiveCfg = Release|Any CPU 39 | {D077C127-1161-41F5-BC74-FBDCCE294812}.Release|x64.Build.0 = Release|Any CPU 40 | EndGlobalSection 41 | GlobalSection(SolutionProperties) = preSolution 42 | HideSolutionNode = FALSE 43 | EndGlobalSection 44 | GlobalSection(ExtensibilityGlobals) = postSolution 45 | SolutionGuid = {E0FCA274-2729-4720-9262-C1983BE5D378} 46 | EndGlobalSection 47 | EndGlobal 48 | -------------------------------------------------------------------------------- /EverythingNet.Tests/LogicSearchTests.cs: -------------------------------------------------------------------------------- 1 | using EverythingNet.Core; 2 | using EverythingNet.Extensions; 3 | using NUnit.Framework; 4 | 5 | namespace EverythingNet.Tests 6 | { 7 | [TestFixture] 8 | public class LogicSearchTests 9 | { 10 | private Everything everyThing; 11 | 12 | [SetUp] 13 | public void Setup() 14 | { 15 | this.everyThing = new Everything(); 16 | } 17 | 18 | [TearDown] 19 | public void TearDown() 20 | { 21 | this.everyThing.CleanUp(); 22 | } 23 | 24 | [TestCase("*.abc", ExpectedResult = "*.abc")] 25 | [TestCase("Any value", ExpectedResult = "\"Any value\"")] 26 | public string Is(string search) 27 | { 28 | this.everyThing.Is(search); 29 | 30 | return everyThing.SearchText; 31 | } 32 | 33 | [TestCase("*.abc", "*.def", ExpectedResult = "*.abc|*.def")] 34 | [TestCase("\"Any value\"", "\"another value\"", ExpectedResult = "\"Any value\"|\"another value\"")] 35 | public string Or(string search1, string search2) 36 | { 37 | this.everyThing 38 | .Is(search1) 39 | .Or() 40 | .Is(search2); 41 | 42 | return everyThing.SearchText; 43 | } 44 | 45 | [TestCase("*.abc", "*.def", ExpectedResult = "*.abc *.def")] 46 | [TestCase("\"Any value\"", "\"another value\"", ExpectedResult = "\"Any value\" \"another value\"")] 47 | 48 | public string And(string search1, string search2) 49 | { 50 | this.everyThing 51 | .Is(search1) 52 | .And() 53 | .Is(search2); 54 | 55 | return everyThing.SearchText; 56 | } 57 | 58 | [TestCase("*.abc", "*.def", ExpectedResult = "*.abc !*.def")] 59 | public string Not(string search1, string search2) 60 | { 61 | this.everyThing 62 | .Is(search1) 63 | .And().Not() 64 | .Is(search2); 65 | 66 | return everyThing.SearchText; 67 | } 68 | 69 | [TestCase(2002, ExpectedResult = "year:>=2002")] 70 | public string GreaterOrEqual(int value) 71 | { 72 | this.everyThing.Is("year:").GreaterOrEqualThan(value); 73 | 74 | return everyThing.SearchText; 75 | } 76 | 77 | [TestCase(2002, ExpectedResult = "year:<=2002")] 78 | public string LessOrEqual(int value) 79 | { 80 | this.everyThing.Is("year:").LessOrEqualThan(value); 81 | 82 | return everyThing.SearchText; 83 | } 84 | 85 | [TestCase(2002, ExpectedResult = "year:>2002")] 86 | public string Greater(int value) 87 | { 88 | this.everyThing.Is("year:").GreaterThan(value); 89 | 90 | return everyThing.SearchText; 91 | } 92 | 93 | [TestCase(2002, ExpectedResult = "year:<2002")] 94 | public string Less(int value) 95 | { 96 | this.everyThing.Is("year:").LessThan(value); 97 | 98 | return everyThing.SearchText; 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /EverythingNet/Query/NameQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | using EverythingNet.Interfaces; 8 | 9 | internal class NameQueryable : Queryable, INameQueryable 10 | { 11 | private string pattern; 12 | private string startWith; 13 | private string endWith; 14 | private string extensions; 15 | 16 | public NameQueryable(IEverythingInternal everything, IQueryGenerator parent) 17 | : base(everything, parent) 18 | { 19 | this.Flags = RequestFlags.EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME; 20 | } 21 | 22 | public INameQueryable Contains(string contains) 23 | { 24 | this.pattern = this.QuoteIfNeeded(contains); 25 | 26 | return this; 27 | } 28 | 29 | public override IEnumerable GetQueryParts() 30 | { 31 | foreach (var queryPart in base.GetQueryParts()) 32 | { 33 | yield return queryPart; 34 | } 35 | 36 | if (!string.IsNullOrEmpty(this.startWith)) 37 | { 38 | yield return $"startwith:{this.startWith}"; 39 | } 40 | 41 | if (!string.IsNullOrEmpty(this.pattern)) 42 | { 43 | yield return this.pattern; 44 | } 45 | 46 | if (!string.IsNullOrEmpty(this.endWith)) 47 | { 48 | yield return $"endwith:{this.endWith}"; 49 | } 50 | 51 | if (!string.IsNullOrEmpty(this.extensions)) 52 | { 53 | yield return $"ext:{this.extensions}"; 54 | } 55 | } 56 | 57 | public INameQueryable StartWith(string pattern) 58 | { 59 | this.startWith = this.QuoteIfNeeded(pattern); 60 | 61 | return this; 62 | } 63 | 64 | public INameQueryable EndWith(string pattern) 65 | { 66 | this.endWith = this.QuoteIfNeeded(pattern); 67 | 68 | return this; 69 | } 70 | 71 | public INameQueryable Extension(string extension) 72 | { 73 | if (extension.Contains(".")) 74 | { 75 | throw new ArgumentException("Do not specify the dot character when specifying an extension"); 76 | } 77 | 78 | this.extensions = string.IsNullOrEmpty(this.extensions) 79 | ? extension 80 | : $"{this.extensions};{extension}"; 81 | 82 | return this; 83 | } 84 | 85 | public INameQueryable Extensions(IEnumerable newExtensions) 86 | { 87 | return this.ExtensionCollection(newExtensions); 88 | } 89 | 90 | public INameQueryable Extensions(params string[] newExtensions) 91 | { 92 | return this.ExtensionCollection(newExtensions); 93 | } 94 | 95 | private INameQueryable ExtensionCollection(IEnumerable newExtensions) 96 | { 97 | if (newExtensions == null) 98 | { 99 | throw new ArgumentNullException(nameof(newExtensions)); 100 | } 101 | 102 | if (!newExtensions.Any()) 103 | { 104 | throw new ArgumentException("The list of exceptions must not be empty"); 105 | } 106 | 107 | if (newExtensions.Any(x => x.Contains("."))) 108 | { 109 | throw new ArgumentException("Do not specify the dot character when specifying an extension"); 110 | } 111 | 112 | return this.Extension(string.Join(";", newExtensions)); 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /EverythingNet/Query/DateQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using EverythingNet.Core; 7 | using EverythingNet.Interfaces; 8 | 9 | internal class DateQueryable : Queryable, IDateQueryable 10 | { 11 | private string searchPattern; 12 | 13 | internal DateQueryable(IEverythingInternal everything, IQueryGenerator parent, string kind) 14 | : base(everything, parent) 15 | { 16 | this.searchPattern = kind; 17 | EverythingWrapper.FileInfoIndex fileInfoIndex; 18 | 19 | switch (this.searchPattern) 20 | { 21 | default: 22 | this.Flags = RequestFlags.EVERYTHING_REQUEST_DATE_MODIFIED; 23 | fileInfoIndex = EverythingWrapper.FileInfoIndex.DateModified; 24 | break; 25 | case "dc": 26 | this.Flags = RequestFlags.EVERYTHING_REQUEST_DATE_CREATED; 27 | fileInfoIndex = EverythingWrapper.FileInfoIndex.DateCreated; 28 | break; 29 | case "dr": 30 | this.Flags = RequestFlags.EVERYTHING_REQUEST_DATE_RUN; 31 | fileInfoIndex = EverythingWrapper.FileInfoIndex.DateAccessed; 32 | break; 33 | case "da": 34 | this.Flags = RequestFlags.EVERYTHING_REQUEST_DATE_ACCESSED; 35 | fileInfoIndex = EverythingWrapper.FileInfoIndex.DateAccessed; 36 | break; 37 | } 38 | 39 | this.IsFast = EverythingWrapper.Everything_IsFileInfoIndexed(fileInfoIndex); 40 | } 41 | 42 | public IDateQueryable Before(DateTime date) 43 | { 44 | return this.DateSearch($"<{date.ToShortDateString()}"); 45 | } 46 | 47 | public IDateQueryable After(DateTime date) 48 | { 49 | return this.DateSearch($">{date.ToShortDateString()}"); 50 | } 51 | 52 | public IDateQueryable Equal(DateTime date) 53 | { 54 | return this.DateSearch($"={date.ToShortDateString()}"); 55 | } 56 | 57 | public IDateQueryable Between(DateTime from, DateTime to) 58 | { 59 | return this.DateSearch($"{from.ToShortDateString()}-{to.ToShortDateString()}"); 60 | } 61 | 62 | public IDateQueryable Before(Dates date) 63 | { 64 | return this.DateSearch($"<{date}"); 65 | } 66 | 67 | public IDateQueryable After(Dates date) 68 | { 69 | return this.DateSearch($">{date}"); 70 | } 71 | 72 | public IDateQueryable Equal(Dates date) 73 | { 74 | return this.DateSearch($"{date}"); 75 | } 76 | 77 | public IDateQueryable Between(Dates from, Dates to) 78 | { 79 | return this.DateSearch($"{from}-{to}"); 80 | } 81 | 82 | public IDateQueryable Last(int count, CountableDates date) 83 | { 84 | return this.DateSearch($"last{count}{date}"); 85 | } 86 | 87 | public IDateQueryable Next(int count, CountableDates date) 88 | { 89 | return this.DateSearch($"next{count}{date}"); 90 | } 91 | 92 | public override IEnumerable GetQueryParts() 93 | { 94 | foreach (var queryPart in base.GetQueryParts()) 95 | { 96 | yield return queryPart; 97 | } 98 | 99 | yield return this.searchPattern; 100 | } 101 | 102 | private IDateQueryable DateSearch(string pattern) 103 | { 104 | this.searchPattern += pattern; 105 | 106 | return this; 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at ju2pom@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /EverythingNet/Query/FileQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System.Collections.Generic; 4 | 5 | using EverythingNet.Core; 6 | using EverythingNet.Interfaces; 7 | 8 | internal class FileQueryable : Queryable, IFileQueryable 9 | { 10 | private const string AudioExt = "aac;ac3;aif;aifc;aiff;au;cda;dts;fla;flac;it;m1a;m2a;m3u;m4a;mid;midi;mka;mod;mp2;mp3;mpa;ogg;ra;rmi;spc;rmi;snd;umx;voc;wav;wma;xm"; 11 | private const string ZipExt = "7z;ace;arj;bz2;cab;gz;gzip;jar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;rar;tar;tgz;z;zip"; 12 | private const string DocExt = "c;chm;cpp;csv;cxx;doc;docm;docx;dot;dotm;dotx;h;hpp;htm;html;hxx;ini;java;lua;mht;mhtml;odt;pdf;potx;potm;ppam;ppsm;ppsx;pps;ppt;pptm;pptx;rtf;sldm;sldx;thmx;txt;vsd;wpd;wps;wri;xlam;xls;xlsb;xlsm;xlsx;xltm;xltx;xml"; 13 | private const string ExeExt = "bat;cmd;exe;msi;msp;msu;scr"; 14 | private const string PicsExt = "ani;bmp;gif;ico;jpe;jpeg;jpg;pcx;png;psd;tga;tif;tiff;wmf"; 15 | private const string VideoExt = "3g2;3gp;3gp2;3gpp;amr;amv;asf;avi;bdmv;bik;d2v;divx;drc;dsa;dsm;dss;dsv;evo;f4v;flc;fli;flic;flv;hdmov;ifo;ivf;m1v;m2p;m2t;m2ts;m2v;m4b;m4p;m4v;mkv;mp2v;mp4;mp4v;mpe;mpeg;mpg;mpls;mpv2;mpv4;mov;mts;ogm;ogv;pss;pva;qt;ram;ratdvd;rm;rmm;rmvb;roq;rpm;smil;smk;swf;tp;tpr;ts;vob;vp6;webm;wm;wmp;wmv"; 16 | 17 | private string searchPattern; 18 | 19 | public FileQueryable(IEverythingInternal everything, IQueryGenerator parent) 20 | : base(everything, parent) 21 | { 22 | this.Flags = RequestFlags.EVERYTHING_REQUEST_EXTENSION|RequestFlags.EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME; 23 | this.IsFast = true; 24 | } 25 | 26 | public IFileQueryable Roots() 27 | { 28 | return this.Macro("root:", string.Empty); 29 | } 30 | 31 | public IFileQueryable Parent(string parentFolder) 32 | { 33 | return this.Macro($"parent:{this.QuoteIfNeeded(parentFolder)}", string.Empty); 34 | } 35 | 36 | public IFileQueryable Audio(string search = null) 37 | { 38 | return this.Macro($"ext:{AudioExt}", search); 39 | } 40 | 41 | public IFileQueryable Zip(string search = null) 42 | { 43 | return this.Macro($"ext:{ZipExt}", search); 44 | } 45 | 46 | public IFileQueryable Video(string search = null) 47 | { 48 | return this.Macro($"ext:{VideoExt}", search); 49 | } 50 | 51 | public IFileQueryable Picture(string search = null) 52 | { 53 | return this.Macro($"ext:{PicsExt}", search); 54 | } 55 | 56 | public IFileQueryable Exe(string search = null) 57 | { 58 | return this.Macro($"ext:{ExeExt}", search); 59 | } 60 | 61 | public IFileQueryable Document(string search = null) 62 | { 63 | return this.Macro($"ext:{DocExt}", search); 64 | } 65 | 66 | public IFileQueryable Duplicates(string search = null) 67 | { 68 | this.searchPattern = $"dupe:{this.QuoteIfNeeded(search)}"; 69 | 70 | return this; 71 | } 72 | 73 | public override IEnumerable GetQueryParts() 74 | { 75 | foreach (var queryPart in base.GetQueryParts()) 76 | { 77 | yield return queryPart; 78 | } 79 | 80 | if (!string.IsNullOrEmpty(this.searchPattern)) 81 | { 82 | yield return this.searchPattern; 83 | } 84 | } 85 | 86 | private IFileQueryable Macro(string tag, string search) 87 | { 88 | this.searchPattern = string.IsNullOrEmpty(search) 89 | ? tag 90 | : $"{tag} {this.QuoteIfNeeded(search)}"; 91 | 92 | return this; 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /EverythingNet/Extensions/DateSearch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using EverythingNet.Core; 3 | 4 | namespace EverythingNet.Extensions 5 | { 6 | public static class DateSearch 7 | { 8 | public enum Dates 9 | { 10 | Year, Month, Week, 11 | } 12 | 13 | public enum Months 14 | { 15 | January, February, March, April, May, June, July, August, September, October, November, December, 16 | } 17 | 18 | public enum Days 19 | { 20 | Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, 21 | } 22 | 23 | public enum Times 24 | { 25 | Hours, Minutes, Seconds, 26 | } 27 | 28 | 29 | public static IEverything DateCreated(this IEverything everything) 30 | { 31 | return Date(everything, "dc:"); 32 | } 33 | 34 | public static IEverything DateCreated(this IEverything everything, DateTime date) 35 | { 36 | return Date(everything, $"dc:{date.ToShortDateString()}"); 37 | } 38 | 39 | public static IEverything DateAccess(this IEverything everything) 40 | { 41 | return Date(everything, "da:"); 42 | } 43 | 44 | public static IEverything DateAccess(this IEverything everything, DateTime date) 45 | { 46 | return Date(everything, $"da:{date.ToShortDateString()}"); 47 | } 48 | 49 | public static IEverything DateModified(this IEverything everything) 50 | { 51 | return Date(everything, "dm:"); 52 | } 53 | 54 | public static IEverything DateModified(this IEverything everything, DateTime date) 55 | { 56 | return Date(everything, $"dm:{date.ToShortDateString()}"); 57 | } 58 | 59 | public static IEverything DateRun(this IEverything everything) 60 | { 61 | return Date(everything, "dr:"); 62 | } 63 | 64 | public static IEverything Today(this IEverything everything) 65 | { 66 | return Date(everything, "today"); 67 | } 68 | 69 | public static IEverything Yesterday(this IEverything everything) 70 | { 71 | return Date(everything, "yesterday"); 72 | } 73 | 74 | public static IEverything This(this IEverything everything, Dates date) 75 | { 76 | return Date(everything, $"this{date.ToString().ToLower()}"); 77 | } 78 | 79 | public static IEverything This(this IEverything everything, Times times) 80 | { 81 | return Date(everything, $"this{times.ToString().ToLower()}"); 82 | } 83 | 84 | public static IEverything Last(this IEverything everything, Dates date, int num = 0) 85 | { 86 | return Date(everything, "last", date, num, "s"); 87 | } 88 | 89 | public static IEverything Last(this IEverything everything, Times times, int num = 0) 90 | { 91 | return Date(everything, "last", times, num, String.Empty); 92 | } 93 | 94 | public static IEverything Next(this IEverything everything, Dates date, int num = 0) 95 | { 96 | return Date(everything, "next", date, num, "s"); 97 | } 98 | 99 | public static IEverything Next(this IEverything everything, Times times, int num = 0) 100 | { 101 | return Date(everything, "next", times, num, string.Empty); 102 | } 103 | 104 | private static IEverything Date(IEverything everything, string date) 105 | { 106 | everything.SearchText += date; 107 | 108 | return everything; 109 | } 110 | 111 | private static IEverything Date(IEverything everything, string tag, Enum date, int num, string plural) 112 | { 113 | string dateString = date.ToString().ToLower(); 114 | 115 | return Date(everything, num > 0 ? $"{tag}{num}{dateString}{plural}" : $"{tag}{dateString}"); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /EverythingNet/Core/Everything.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Core 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading; 7 | 8 | using EverythingNet.Interfaces; 9 | using EverythingNet.Query; 10 | 11 | public class Everything : IEverythingInternal, IDisposable 12 | { 13 | private static int lastReplyId; 14 | 15 | private const uint DefaultSearchFlags = (uint)( 16 | RequestFlags.EVERYTHING_REQUEST_SIZE 17 | | RequestFlags.EVERYTHING_REQUEST_FILE_NAME 18 | | RequestFlags.EVERYTHING_REQUEST_EXTENSION 19 | | RequestFlags.EVERYTHING_REQUEST_PATH 20 | | RequestFlags.EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME 21 | | RequestFlags.EVERYTHING_REQUEST_DATE_MODIFIED); 22 | 23 | private readonly uint replyId; 24 | 25 | public Everything() 26 | { 27 | this.ResulKind = ResultKind.Both; 28 | Interlocked.Increment(ref lastReplyId); 29 | this.replyId = Convert.ToUInt32(lastReplyId); 30 | if (!EverythingState.IsStarted()) 31 | { 32 | throw new InvalidOperationException("Everything service must be started"); 33 | } 34 | } 35 | 36 | public ResultKind ResulKind { get; set; } 37 | 38 | public bool MatchCase { get; set; } 39 | 40 | public bool MatchPath { get; set; } 41 | 42 | public bool MatchWholeWord { get; set; } 43 | 44 | public SortingKey SortKey { get; set; } 45 | 46 | public ErrorCode LastErrorCode { get; set; } 47 | 48 | public long Count => EverythingWrapper.Everything_GetNumResults(); 49 | 50 | public IQuery Search() 51 | { 52 | return new Query(this); 53 | } 54 | 55 | public void Reset() 56 | { 57 | EverythingWrapper.Everything_Reset(); 58 | } 59 | 60 | public void Dispose() 61 | { 62 | this.Reset(); 63 | } 64 | 65 | IEnumerable IEverythingInternal.SendSearch(string searchPattern, RequestFlags flags) 66 | { 67 | using (EverythingWrapper.Lock()) 68 | { 69 | EverythingWrapper.Everything_SetReplyID(this.replyId); 70 | EverythingWrapper.Everything_SetMatchWholeWord(this.MatchWholeWord); 71 | EverythingWrapper.Everything_SetMatchPath(this.MatchPath); 72 | EverythingWrapper.Everything_SetMatchCase(this.MatchCase); 73 | EverythingWrapper.Everything_SetRequestFlags((uint)flags|DefaultSearchFlags); 74 | searchPattern = this.ApplySearchResultKind(searchPattern); 75 | EverythingWrapper.Everything_SetSearch(searchPattern); 76 | 77 | if (this.SortKey != SortingKey.None) 78 | { 79 | EverythingWrapper.Everything_SetSort((uint)this.SortKey); 80 | } 81 | 82 | EverythingWrapper.Everything_Query(true); 83 | 84 | this.LastErrorCode = this.GetError(); 85 | 86 | return this.GetResults(); 87 | } 88 | } 89 | 90 | private string ApplySearchResultKind(string searchPatten) 91 | { 92 | switch (this.ResulKind) 93 | { 94 | case ResultKind.FilesOnly: 95 | return $"files: {searchPatten}"; 96 | case ResultKind.FoldersOnly: 97 | return $"folders: {searchPatten}"; 98 | default: 99 | return searchPatten; 100 | } 101 | } 102 | 103 | private IEnumerable GetResults() 104 | { 105 | var numResults = EverythingWrapper.Everything_GetNumResults(); 106 | 107 | return Enumerable.Range(0, (int)numResults).Select(x => new SearchResult(x, this.replyId)); 108 | } 109 | 110 | private ErrorCode GetError() 111 | { 112 | var error = EverythingWrapper.Everything_GetLastError(); 113 | 114 | return (ErrorCode)error; 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /EverythingNet.Tests/EverythingTests.cs: -------------------------------------------------------------------------------- 1 | using EverythingNet.Core; 2 | 3 | namespace EverythingNet.Tests 4 | { 5 | using System.IO; 6 | using System.Linq; 7 | using System.Reflection; 8 | 9 | using NUnit.Framework; 10 | 11 | [TestFixture] 12 | //[Ignore("Everything service don't run on Appveyor")] 13 | public class EverythingTests 14 | { 15 | private Everything everyThing; 16 | 17 | [SetUp] 18 | public void Setup() 19 | { 20 | this.everyThing = new Everything(); 21 | } 22 | 23 | [TearDown] 24 | public void TearDown() 25 | { 26 | this.everyThing.CleanUp(); 27 | } 28 | 29 | [TestCase("text1")] 30 | [TestCase("text2")] 31 | public void SearchText(string searchText) 32 | { 33 | // Act 34 | this.everyThing.SearchText = searchText; 35 | 36 | // Assert 37 | Assert.AreEqual(searchText, this.everyThing.SearchText); 38 | } 39 | 40 | [TestCase(true)] 41 | [TestCase(false)] 42 | public void MatchCase(bool matchCase) 43 | { 44 | // Act 45 | this.everyThing.MatchCase = matchCase; 46 | 47 | // Assert 48 | Assert.AreEqual(matchCase, this.everyThing.MatchCase); 49 | } 50 | 51 | [TestCase(true)] 52 | [TestCase(false)] 53 | public void MatchPath(bool matchPath) 54 | { 55 | // Act 56 | this.everyThing.MatchPath = matchPath; 57 | 58 | // Assert 59 | Assert.AreEqual(matchPath, this.everyThing.MatchPath); 60 | } 61 | 62 | [TestCase(true)] 63 | [TestCase(false)] 64 | public void MatchWholeWord(bool matchWholeWord) 65 | { 66 | // Act 67 | this.everyThing.MatchWholeWord = matchWholeWord; 68 | 69 | // Assert 70 | Assert.AreEqual(matchWholeWord, this.everyThing.MatchWholeWord); 71 | } 72 | 73 | [Test] 74 | public void Search() 75 | { 76 | // Arrange 77 | string searchText = Assembly.GetExecutingAssembly().GetName().Name + ".dll"; 78 | this.everyThing.SearchText = searchText; 79 | this.everyThing.MatchWholeWord = true; 80 | 81 | // Act 82 | ISearchResult results = this.everyThing.Search(true); 83 | 84 | // Assert 85 | Assert.That(results.ErrorCode, Is.EqualTo(ErrorCode.Ok)); 86 | CollectionAssert.IsNotEmpty(results.Results); 87 | } 88 | 89 | [TestCase("*.cs")] 90 | [TestCase("*.sln")] 91 | [TestCase("*.csproj")] 92 | [TestCase("packages.config")] 93 | public void Search_Images(string searchText) 94 | { 95 | // Arrange 96 | this.everyThing.SearchText = searchText; 97 | this.everyThing.MatchWholeWord = true; 98 | 99 | // Act 100 | ISearchResult results = this.everyThing.Search(true); 101 | 102 | // Assert 103 | Assert.That(results.ErrorCode, Is.EqualTo(ErrorCode.Ok)); 104 | CollectionAssert.IsNotEmpty(results.Results); 105 | } 106 | 107 | [TestCase("child:cr2|nef|srw|arw|crw|mrw|raf|pef|orf|rw2|nrw|dng")] 108 | public void Search_ForFolders(string searchText) 109 | { 110 | // Arrange 111 | this.everyThing.SearchText = searchText; 112 | 113 | // Act 114 | ISearchResult results = this.everyThing.Search(true); 115 | 116 | // Assert 117 | Assert.That(results.ErrorCode, Is.EqualTo(ErrorCode.Ok)); 118 | CollectionAssert.IsNotEmpty(results.Results); 119 | results.Results.ToList().ForEach(x => Directory.Exists(x)); 120 | } 121 | 122 | [TestCase("parents:0")] 123 | public void Search_ForRootFolders(string searchText) 124 | { 125 | // Arrange 126 | this.everyThing.SearchText = searchText; 127 | 128 | // Act 129 | ISearchResult results = this.everyThing.Search(true); 130 | 131 | // Assert 132 | Assert.That(results.ErrorCode, Is.EqualTo(ErrorCode.Ok)); 133 | CollectionAssert.IsNotEmpty(results.Results); 134 | results.Results.ToList().ForEach(x => Directory.Exists(x)); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /EverythingNet.Tests/NameQueryableTests.cs: -------------------------------------------------------------------------------- 1 | using EverythingNet.Core; 2 | using NUnit.Framework; 3 | 4 | namespace EverythingNet.Tests 5 | { 6 | [TestFixture] 7 | public class NameQueryable 8 | { 9 | private Everything everyThing; 10 | 11 | [SetUp] 12 | public void Setup() 13 | { 14 | this.everyThing = new Everything(); 15 | } 16 | 17 | [TearDown] 18 | public void TearDown() 19 | { 20 | this.everyThing.Dispose(); 21 | } 22 | 23 | [TestCase("*.abc", ExpectedResult = "*.abc")] 24 | [TestCase("Any value", ExpectedResult = "\"Any value\"")] 25 | public string Contains(string name) 26 | { 27 | var queryable = this.everyThing 28 | .Search() 29 | .Name 30 | .Contains(name); 31 | 32 | return queryable.ToString(); 33 | } 34 | 35 | [TestCase("*.abc", "*.def", ExpectedResult = "*.abc|*.def")] 36 | [TestCase("\"Any value\"", "\"another value\"", ExpectedResult = "\"Any value\"|\"another value\"")] 37 | public string Or(string search1, string search2) 38 | { 39 | var queryable = this.everyThing 40 | .Search() 41 | .Name 42 | .Contains(search1) 43 | .Or 44 | .Name 45 | .Contains(search2); 46 | 47 | return queryable.ToString(); 48 | } 49 | 50 | [TestCase("*.abc", "*.def", ExpectedResult = "*.abc *.def")] 51 | [TestCase("\"Any value\"", "\"another value\"", ExpectedResult = "\"Any value\" \"another value\"")] 52 | 53 | public string And(string search1, string search2) 54 | { 55 | var queryable = this.everyThing 56 | .Search() 57 | .Name 58 | .Contains(search1) 59 | .And 60 | .Name 61 | .Contains(search2); 62 | 63 | return queryable.ToString(); 64 | } 65 | 66 | [TestCase("*.abc", "*.def", ExpectedResult = "*.abc !*.def")] 67 | public string Not(string search1, string search2) 68 | { 69 | var queryable = this.everyThing 70 | .Search() 71 | .Name 72 | .Contains(search1) 73 | .And 74 | .Not 75 | .Name 76 | .Contains(search2); 77 | 78 | return queryable.ToString(); 79 | } 80 | 81 | [TestCase("prefix", ExpectedResult = "startwith:prefix")] 82 | public string StartWith(string pattern) 83 | { 84 | var queryable = this.everyThing 85 | .Search() 86 | .Name 87 | .StartWith(pattern); 88 | 89 | return queryable.ToString(); 90 | } 91 | 92 | [TestCase("postfix", ExpectedResult = "endwith:postfix")] 93 | public string EndWith(string pattern) 94 | { 95 | var queryable = this.everyThing 96 | .Search() 97 | .Name 98 | .EndWith(pattern); 99 | 100 | return queryable.ToString(); 101 | } 102 | 103 | [TestCase("cs", ExpectedResult = "ext:cs")] 104 | [TestCase("xaml", ExpectedResult = "ext:xaml")] 105 | public string Extension(string search) 106 | { 107 | var queryable = this.everyThing. 108 | Search() 109 | .Name 110 | .Extension(search); 111 | 112 | return queryable.ToString(); 113 | } 114 | 115 | [TestCase("cs csproj xaml", ExpectedResult = "ext:cs;csproj;xaml")] 116 | [TestCase("jpg png tif", ExpectedResult = "ext:jpg;png;tif")] 117 | public string Extensions(string search) 118 | { 119 | var extensions = search.Split(' '); 120 | var queryable = this.everyThing 121 | .Search() 122 | .Name 123 | .Extensions(extensions); 124 | 125 | return queryable.ToString(); 126 | } 127 | 128 | [Test] 129 | public void ExtensionsWithParam() 130 | { 131 | var queryable = this.everyThing 132 | .Search() 133 | .Name 134 | .Extensions("jpg", "png", "bmp", "tif"); 135 | 136 | Assert.That(queryable.ToString(), Is.EqualTo("ext:jpg;png;bmp;tif")); 137 | } 138 | 139 | [Test] 140 | public void AcceptanceTest() 141 | { 142 | var queryable = new Everything() 143 | .Search() 144 | .Name.Contains("user"); 145 | 146 | Assert.That(queryable.Count, Is.GreaterThan(0)); 147 | } 148 | } 149 | } -------------------------------------------------------------------------------- /EverythingNet/EverythingNet.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C6CC7352-F58B-4274-B629-A15A7F3C69CD} 8 | Library 9 | Properties 10 | EverythingNet 11 | EverythingNet 12 | v4.6.2 13 | 512 14 | 15 | 16 | 17 | true 18 | bin\x64\Debug\ 19 | DEBUG;TRACE 20 | full 21 | x64 22 | prompt 23 | MinimumRecommendedRules.ruleset 24 | true 25 | 26 | 27 | bin\x64\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | x64 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | true 35 | 36 | 37 | OnOutputUpdated 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /EverythingNet/Core/SearchResult.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Core 2 | { 3 | using System; 4 | using System.IO; 5 | using System.Text; 6 | 7 | using EverythingNet.Interfaces; 8 | 9 | internal class SearchResult : ISearchResult 10 | { 11 | private delegate bool MyDelegate(uint index, out long date); 12 | 13 | private readonly uint replyId; 14 | private readonly uint index; 15 | 16 | private string fullPath; 17 | 18 | public SearchResult(int index, uint replyId) 19 | { 20 | this.replyId = replyId; 21 | this.index = Convert.ToUInt32(index); 22 | } 23 | 24 | public long Index => this.index; 25 | 26 | public bool IsFile => EverythingWrapper.Everything_IsFileResult(this.index); 27 | 28 | public string FullPath 29 | { 30 | get 31 | { 32 | if (this.fullPath == null) 33 | { 34 | var builder = new StringBuilder(260); 35 | 36 | EverythingWrapper.Everything_SetReplyID(this.replyId); 37 | EverythingWrapper.Everything_GetResultFullPathName(this.index, builder, 260); 38 | 39 | this.fullPath = builder.ToString(); 40 | } 41 | 42 | return this.fullPath; 43 | } 44 | } 45 | 46 | public string Path 47 | { 48 | get 49 | { 50 | //EverythingWrapper.Everything_SetReplyID(this.replyId); 51 | //return EverythingWrapper.Everything_GetResultPath(this.index); 52 | 53 | // Temporary implementation until the native function works as expected 54 | try 55 | { 56 | return !string.IsNullOrEmpty(this.FullPath) 57 | ? System.IO.Path.GetDirectoryName(this.FullPath) 58 | : string.Empty; 59 | } 60 | catch (Exception e) 61 | { 62 | this.LastException = e; 63 | 64 | return this.FullPath; 65 | } 66 | } 67 | } 68 | 69 | public string FileName 70 | { 71 | get 72 | { 73 | //EverythingWrapper.Everything_SetReplyID(this.replyId); 74 | //return EverythingWrapper.Everything_GetResultFileName(this.index); 75 | 76 | // Temporary implementation until the native function works as expected 77 | try 78 | { 79 | return !string.IsNullOrEmpty(this.FullPath) 80 | ? System.IO.Path.GetFileName(this.FullPath) 81 | : string.Empty; 82 | } 83 | catch (Exception e) 84 | { 85 | this.LastException = e; 86 | 87 | return this.FullPath; 88 | } 89 | } 90 | } 91 | 92 | public long Size 93 | { 94 | get 95 | { 96 | EverythingWrapper.Everything_SetReplyID(this.replyId); 97 | EverythingWrapper.Everything_GetResultSize(this.index, out var size); 98 | 99 | return size; 100 | } 101 | } 102 | 103 | public uint Attributes 104 | { 105 | get 106 | { 107 | EverythingWrapper.Everything_SetReplyID(this.replyId); 108 | uint attributes = EverythingWrapper.Everything_GetResultAttributes(this.index); 109 | 110 | return attributes > 0 111 | ? attributes 112 | : (!string.IsNullOrEmpty(this.FullPath) 113 | ? (uint)File.GetAttributes(this.FullPath) 114 | : 0); 115 | } 116 | } 117 | 118 | public DateTime Created => this.GenericDate(EverythingWrapper.Everything_GetResultDateCreated, File.GetCreationTime); 119 | 120 | public DateTime Modified => this.GenericDate(EverythingWrapper.Everything_GetResultDateModified, File.GetLastWriteTime); 121 | 122 | public DateTime Accessed => this.GenericDate(EverythingWrapper.Everything_GetResultDateAccessed, File.GetLastAccessTime); 123 | 124 | public DateTime Executed => this.GenericDate(EverythingWrapper.Everything_GetResultDateRun, File.GetLastAccessTime); 125 | 126 | public Exception LastException { get; private set; } 127 | 128 | private DateTime GenericDate(MyDelegate func, Func fallbackDelegate) 129 | { 130 | EverythingWrapper.Everything_SetReplyID(this.replyId); 131 | if (func(this.index, out var date) && date >= 0) 132 | { 133 | return DateTime.FromFileTime(date); 134 | } 135 | 136 | return !string.IsNullOrEmpty(this.FullPath) 137 | ? fallbackDelegate(this.FullPath) 138 | : DateTime.MinValue; 139 | } 140 | } 141 | } -------------------------------------------------------------------------------- /EverythingNet.Bench/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /EverythingNet.Tests/SizeSearchTests.cs: -------------------------------------------------------------------------------- 1 | using EverythingNet.Core; 2 | using EverythingNet.Query; 3 | using NUnit.Framework; 4 | 5 | namespace EverythingNet.Tests 6 | { 7 | [TestFixture] 8 | public class SizeSearchTests 9 | { 10 | private Everything everyThing; 11 | 12 | [SetUp] 13 | public void Setup() 14 | { 15 | this.everyThing = new Everything(); 16 | } 17 | 18 | [TearDown] 19 | public void TearDown() 20 | { 21 | this.everyThing.Dispose(); 22 | } 23 | 24 | [TestCase(Sizes.Empty, ExpectedResult = "size:empty")] 25 | [TestCase(Sizes.Gigantic, ExpectedResult = "size:gigantic")] 26 | [TestCase(Sizes.Huge, ExpectedResult = "size:huge")] 27 | [TestCase(Sizes.Large, ExpectedResult = "size:large")] 28 | [TestCase(Sizes.Medium, ExpectedResult = "size:medium")] 29 | [TestCase(Sizes.Small, ExpectedResult = "size:small")] 30 | [TestCase(Sizes.Tiny, ExpectedResult = "size:tiny")] 31 | [TestCase(Sizes.Unknown, ExpectedResult = "size:unknown")] 32 | public string StandardSize(Sizes standardSize) 33 | { 34 | var queryable = this.everyThing 35 | .Search() 36 | .Size 37 | .Equal(standardSize); 38 | 39 | return queryable.ToString(); 40 | } 41 | 42 | [TestCase(SizeUnit.Kb, 10, ExpectedResult = "size:>10kb")] 43 | [TestCase(SizeUnit.Mb, 10, ExpectedResult = "size:>10mb")] 44 | [TestCase(SizeUnit.Gb, 10, ExpectedResult = "size:>10gb")] 45 | public string SizeGreater(SizeUnit unit, int value) 46 | { 47 | var queryable = this.everyThing 48 | .Search() 49 | .Size 50 | .GreaterThan(value, unit); 51 | 52 | return queryable.ToString(); 53 | } 54 | 55 | [TestCase(SizeUnit.Kb, 10, ExpectedResult = "size:>=10kb")] 56 | [TestCase(SizeUnit.Mb, 10, ExpectedResult = "size:>=10mb")] 57 | [TestCase(SizeUnit.Gb, 10, ExpectedResult = "size:>=10gb")] 58 | public string SizeGreaterOrEqual(SizeUnit unit, int value) 59 | { 60 | var queryable = this.everyThing 61 | .Search() 62 | .Size 63 | .GreaterOrEqualThan(value, unit); 64 | 65 | return queryable.ToString(); 66 | } 67 | 68 | [TestCase(SizeUnit.Kb, 10, ExpectedResult = "size:<10kb")] 69 | [TestCase(SizeUnit.Mb, 10, ExpectedResult = "size:<10mb")] 70 | [TestCase(SizeUnit.Gb, 10, ExpectedResult = "size:<10gb")] 71 | public string SizeLess(SizeUnit unit, int value) 72 | { 73 | var queryable = this.everyThing 74 | .Search() 75 | .Size 76 | .LessThan(value, unit); 77 | 78 | return queryable.ToString(); 79 | } 80 | 81 | [TestCase(SizeUnit.Kb, 10, ExpectedResult = "size:<=10kb")] 82 | [TestCase(SizeUnit.Mb, 10, ExpectedResult = "size:<=10mb")] 83 | [TestCase(SizeUnit.Gb, 10, ExpectedResult = "size:<=10gb")] 84 | public string SizeLessOrEqual(SizeUnit unit, int value) 85 | { 86 | var queryable = this.everyThing 87 | .Search() 88 | .Size 89 | .LessOrEqualThan(value, unit); 90 | 91 | return queryable.ToString(); 92 | } 93 | 94 | [TestCase(1, 10, ExpectedResult = "size:1Kb-10Kb")] 95 | [TestCase(400, 800, ExpectedResult = "size:400Kb-800Kb")] 96 | [TestCase(1000, 2000, ExpectedResult = "size:1000Kb-2000Kb")] 97 | public string SizeBetweenDefaultUnit(int min, int max) 98 | { 99 | var queryable = this.everyThing 100 | .Search() 101 | .Size 102 | .Between(min, max); 103 | 104 | return queryable.ToString(); 105 | } 106 | 107 | [TestCase(SizeUnit.Kb, 10, 100, ExpectedResult = "size:10Kb-100Kb")] 108 | [TestCase(SizeUnit.Mb, 10, 100, ExpectedResult = "size:10Mb-100Mb")] 109 | [TestCase(SizeUnit.Gb, 10, 100, ExpectedResult = "size:10Gb-100Gb")] 110 | public string SizeBetweenSameUnit(SizeUnit unit, int min, int max) 111 | { 112 | var queryable = this.everyThing 113 | .Search() 114 | .Size 115 | .Between(min, max, unit); 116 | 117 | return queryable.ToString(); 118 | } 119 | 120 | [TestCase(10, SizeUnit.Kb, 100, SizeUnit.Mb, ExpectedResult = "size:10Kb-100Mb")] 121 | [TestCase(10, SizeUnit.Mb, 100, SizeUnit.Gb, ExpectedResult = "size:10Mb-100Gb")] 122 | [TestCase(10, SizeUnit.Kb, 100, SizeUnit.Gb, ExpectedResult = "size:10Kb-100Gb")] 123 | public string SizeBetweenDifferentUnits(int min, SizeUnit minUnit, int max, SizeUnit maxUnit) 124 | { 125 | var queryable = this.everyThing 126 | .Search() 127 | .Size 128 | .Between(min, minUnit, max, maxUnit); 129 | 130 | return queryable.ToString(); 131 | } 132 | 133 | [Test] 134 | public void AcceptanceTest() 135 | { 136 | var queryable = new Everything() 137 | .Search() 138 | .Size.GreaterThan(10, SizeUnit.Kb); 139 | 140 | Assert.That(queryable.Count, Is.GreaterThan(0)); 141 | } 142 | } 143 | } -------------------------------------------------------------------------------- /EverythingNet/Query/SizeQueryable.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Query 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using EverythingNet.Core; 7 | using EverythingNet.Interfaces; 8 | 9 | public enum SizeUnit 10 | { 11 | Kb = 1, 12 | Mb, 13 | Gb 14 | } 15 | 16 | public enum Sizes 17 | { 18 | Empty, 19 | Unknown, 20 | Tiny, 21 | Small, 22 | Medium, 23 | Large, 24 | Huge, 25 | Gigantic 26 | } 27 | 28 | internal class SizeQueryable : Queryable, ISizeQueryable 29 | { 30 | private ISizeRef sizeRef; 31 | 32 | public SizeQueryable(IEverythingInternal everything, IQueryGenerator parent) 33 | : base(everything, parent) 34 | { 35 | this.Flags = RequestFlags.EVERYTHING_REQUEST_SIZE; 36 | this.IsFast = EverythingWrapper.Everything_IsFileInfoIndexed(EverythingWrapper.FileInfoIndex.FileSize) 37 | && EverythingWrapper.Everything_IsFileInfoIndexed(EverythingWrapper.FileInfoIndex.FolderSize); 38 | } 39 | 40 | public ISizeQueryable Equal(int value) 41 | { 42 | return this.Equal(value, SizeUnit.Kb); 43 | } 44 | 45 | public ISizeQueryable Equal(int value, SizeUnit u) 46 | { 47 | this.sizeRef = new SizeComparison(value, string.Empty, u); 48 | 49 | return this; 50 | } 51 | 52 | public ISizeQueryable Equal(Sizes s) 53 | { 54 | this.sizeRef = new DefaultSize(s); 55 | 56 | return this; 57 | } 58 | 59 | public override IEnumerable GetQueryParts() 60 | { 61 | foreach (var queryPart in base.GetQueryParts()) 62 | { 63 | yield return queryPart; 64 | } 65 | 66 | yield return this.sizeRef.ToString(); 67 | } 68 | 69 | public ISizeQueryable GreaterThan(int value) 70 | { 71 | return this.GreaterThan(value, SizeUnit.Kb); 72 | } 73 | 74 | public ISizeQueryable GreaterThan(int value, SizeUnit u) 75 | { 76 | return this.Comparison(value, ">", u); 77 | } 78 | 79 | public ISizeQueryable GreaterOrEqualThan(int value) 80 | { 81 | return this.GreaterOrEqualThan(value, SizeUnit.Kb); 82 | } 83 | 84 | public ISizeQueryable GreaterOrEqualThan(int value, SizeUnit unit) 85 | { 86 | return this.Comparison(value, ">=", unit); 87 | } 88 | 89 | public ISizeQueryable LessThan(int value) 90 | { 91 | return this.LessThan(value, SizeUnit.Kb); 92 | } 93 | 94 | public ISizeQueryable LessThan(int value, SizeUnit u) 95 | { 96 | return this.Comparison(value, "<", u); 97 | } 98 | 99 | public ISizeQueryable LessOrEqualThan(int value) 100 | { 101 | return this.LessOrEqualThan(value, SizeUnit.Kb); 102 | } 103 | 104 | public ISizeQueryable LessOrEqualThan(int value, SizeUnit unit) 105 | { 106 | return this.Comparison(value, "<=", unit); 107 | } 108 | 109 | public ISizeQueryable Between(int min, int max) 110 | { 111 | return this.Between(min, max, SizeUnit.Kb); 112 | } 113 | 114 | public ISizeQueryable Between(int min, int max, SizeUnit u) 115 | { 116 | return this.Between(min, u, max, u); 117 | } 118 | 119 | public ISizeQueryable Between(int min, SizeUnit u1, int max, SizeUnit u2) 120 | { 121 | if (min * Math.Pow(10, (int)u1) > max * Math.Pow(10, (int)u2)) 122 | { 123 | throw new InvalidOperationException($"Minimum value must be lower or equal to max value: min={min}{u1} max={max}{u2}"); 124 | } 125 | 126 | this.sizeRef = new BetweenSize(min, u1, max, u2); 127 | 128 | return this; 129 | } 130 | 131 | private ISizeQueryable Comparison(int value, string comparison, SizeUnit unit) 132 | { 133 | this.sizeRef = new SizeComparison(value, comparison, unit); 134 | 135 | return this; 136 | } 137 | 138 | private interface ISizeRef 139 | { 140 | } 141 | 142 | private class DefaultSize : ISizeRef 143 | { 144 | private readonly Sizes sizes; 145 | 146 | public DefaultSize(Sizes sizes) 147 | { 148 | this.sizes = sizes; 149 | } 150 | 151 | public override string ToString() 152 | { 153 | return $"size:{this.sizes.ToString().ToLower()}"; 154 | } 155 | } 156 | 157 | private class SizeComparison : ISizeRef 158 | { 159 | private readonly int size; 160 | private readonly string comparison; 161 | private readonly SizeUnit unit; 162 | 163 | public SizeComparison(int size, string comparison, SizeUnit u = SizeUnit.Kb) 164 | { 165 | this.size = size; 166 | this.comparison = comparison; 167 | this.unit = u; 168 | } 169 | 170 | public override string ToString() 171 | { 172 | return $"size:{this.comparison}{this.size}{this.unit.ToString().ToLower()}"; 173 | } 174 | } 175 | 176 | private class BetweenSize : ISizeRef 177 | { 178 | private readonly int minimum; 179 | private readonly SizeUnit minimumUnit; 180 | private readonly int maximum; 181 | private readonly SizeUnit maximumUnit; 182 | 183 | public BetweenSize(int min, SizeUnit minUnit, int max, SizeUnit maxUnit) 184 | { 185 | this.minimum = min; 186 | this.minimumUnit = minUnit; 187 | this.maximum = max; 188 | this.maximumUnit = maxUnit; 189 | } 190 | 191 | public override string ToString() 192 | { 193 | return $"size:{this.minimum}{this.minimumUnit}-{this.maximum}{this.maximumUnit}"; 194 | } 195 | } 196 | } 197 | } -------------------------------------------------------------------------------- /EverythingNet.Tests/FileSearchTests.cs: -------------------------------------------------------------------------------- 1 | using EverythingNet.Core; 2 | using NUnit.Framework; 3 | 4 | namespace EverythingNet.Tests 5 | { 6 | [TestFixture] 7 | public class FileSearchTests 8 | { 9 | private Everything everyThing; 10 | 11 | [SetUp] 12 | public void Setup() 13 | { 14 | this.everyThing = new Everything(); 15 | } 16 | 17 | [TearDown] 18 | public void TearDown() 19 | { 20 | this.everyThing.Dispose(); 21 | } 22 | 23 | [TestCase("", ExpectedResult = "ext:aac;ac3;aif;aifc;aiff;au;cda;dts;fla;flac;it;m1a;m2a;m3u;m4a;mid;midi;mka;mod;mp2;mp3;mpa;ogg;ra;rmi;spc;rmi;snd;umx;voc;wav;wma;xm")] 24 | [TestCase(null, ExpectedResult = "ext:aac;ac3;aif;aifc;aiff;au;cda;dts;fla;flac;it;m1a;m2a;m3u;m4a;mid;midi;mka;mod;mp2;mp3;mpa;ogg;ra;rmi;spc;rmi;snd;umx;voc;wav;wma;xm")] 25 | [TestCase("music.mp3", ExpectedResult = "ext:aac;ac3;aif;aifc;aiff;au;cda;dts;fla;flac;it;m1a;m2a;m3u;m4a;mid;midi;mka;mod;mp2;mp3;mpa;ogg;ra;rmi;spc;rmi;snd;umx;voc;wav;wma;xm music.mp3")] 26 | public string Audio(string search) 27 | { 28 | var queryable = this.everyThing 29 | .Search() 30 | .File 31 | .Audio(search); 32 | 33 | return queryable.ToString(); 34 | } 35 | 36 | [TestCase("", ExpectedResult = "ext:7z;ace;arj;bz2;cab;gz;gzip;jar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;rar;tar;tgz;z;zip")] 37 | [TestCase(null, ExpectedResult = "ext:7z;ace;arj;bz2;cab;gz;gzip;jar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;rar;tar;tgz;z;zip")] 38 | [TestCase("archive.zip", ExpectedResult = "ext:7z;ace;arj;bz2;cab;gz;gzip;jar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;rar;tar;tgz;z;zip archive.zip")] 39 | public string Zip(string search) 40 | { 41 | var queryable = this.everyThing 42 | .Search() 43 | .File 44 | .Zip(search); 45 | 46 | return queryable.ToString(); 47 | } 48 | 49 | 50 | [TestCase("", ExpectedResult = "ext:3g2;3gp;3gp2;3gpp;amr;amv;asf;avi;bdmv;bik;d2v;divx;drc;dsa;dsm;dss;dsv;evo;f4v;flc;fli;flic;flv;hdmov;ifo;ivf;m1v;m2p;m2t;m2ts;m2v;m4b;m4p;m4v;mkv;mp2v;mp4;mp4v;mpe;mpeg;mpg;mpls;mpv2;mpv4;mov;mts;ogm;ogv;pss;pva;qt;ram;ratdvd;rm;rmm;rmvb;roq;rpm;smil;smk;swf;tp;tpr;ts;vob;vp6;webm;wm;wmp;wmv")] 51 | [TestCase(null, ExpectedResult = "ext:3g2;3gp;3gp2;3gpp;amr;amv;asf;avi;bdmv;bik;d2v;divx;drc;dsa;dsm;dss;dsv;evo;f4v;flc;fli;flic;flv;hdmov;ifo;ivf;m1v;m2p;m2t;m2ts;m2v;m4b;m4p;m4v;mkv;mp2v;mp4;mp4v;mpe;mpeg;mpg;mpls;mpv2;mpv4;mov;mts;ogm;ogv;pss;pva;qt;ram;ratdvd;rm;rmm;rmvb;roq;rpm;smil;smk;swf;tp;tpr;ts;vob;vp6;webm;wm;wmp;wmv")] 52 | [TestCase("movie.avi", ExpectedResult = "ext:3g2;3gp;3gp2;3gpp;amr;amv;asf;avi;bdmv;bik;d2v;divx;drc;dsa;dsm;dss;dsv;evo;f4v;flc;fli;flic;flv;hdmov;ifo;ivf;m1v;m2p;m2t;m2ts;m2v;m4b;m4p;m4v;mkv;mp2v;mp4;mp4v;mpe;mpeg;mpg;mpls;mpv2;mpv4;mov;mts;ogm;ogv;pss;pva;qt;ram;ratdvd;rm;rmm;rmvb;roq;rpm;smil;smk;swf;tp;tpr;ts;vob;vp6;webm;wm;wmp;wmv movie.avi")] 53 | public string Video(string search) 54 | { 55 | var queryable = this.everyThing 56 | .Search() 57 | .File 58 | .Video(search); 59 | 60 | return queryable.ToString(); 61 | } 62 | 63 | [TestCase("", ExpectedResult = "ext:ani;bmp;gif;ico;jpe;jpeg;jpg;pcx;png;psd;tga;tif;tiff;wmf")] 64 | [TestCase(null, ExpectedResult = "ext:ani;bmp;gif;ico;jpe;jpeg;jpg;pcx;png;psd;tga;tif;tiff;wmf")] 65 | [TestCase("image.jpg", ExpectedResult = "ext:ani;bmp;gif;ico;jpe;jpeg;jpg;pcx;png;psd;tga;tif;tiff;wmf image.jpg")] 66 | public string Picture(string search) 67 | { 68 | var queryable = this.everyThing 69 | .Search() 70 | .File 71 | .Picture(search); 72 | 73 | return queryable.ToString(); 74 | } 75 | 76 | [TestCase("", ExpectedResult = "ext:bat;cmd;exe;msi;msp;msu;scr")] 77 | [TestCase(null, ExpectedResult = "ext:bat;cmd;exe;msi;msp;msu;scr")] 78 | [TestCase("application.exe", ExpectedResult = "ext:bat;cmd;exe;msi;msp;msu;scr application.exe")] 79 | public string Exe(string search) 80 | { 81 | var queryable = this.everyThing 82 | .Search() 83 | .File 84 | .Exe(search); 85 | 86 | return queryable.ToString(); 87 | } 88 | 89 | [TestCase("", ExpectedResult = "ext:c;chm;cpp;csv;cxx;doc;docm;docx;dot;dotm;dotx;h;hpp;htm;html;hxx;ini;java;lua;mht;mhtml;odt;pdf;potx;potm;ppam;ppsm;ppsx;pps;ppt;pptm;pptx;rtf;sldm;sldx;thmx;txt;vsd;wpd;wps;wri;xlam;xls;xlsb;xlsm;xlsx;xltm;xltx;xml")] 90 | [TestCase(null, ExpectedResult = "ext:c;chm;cpp;csv;cxx;doc;docm;docx;dot;dotm;dotx;h;hpp;htm;html;hxx;ini;java;lua;mht;mhtml;odt;pdf;potx;potm;ppam;ppsm;ppsx;pps;ppt;pptm;pptx;rtf;sldm;sldx;thmx;txt;vsd;wpd;wps;wri;xlam;xls;xlsb;xlsm;xlsx;xltm;xltx;xml")] 91 | [TestCase("report.doc", ExpectedResult = "ext:c;chm;cpp;csv;cxx;doc;docm;docx;dot;dotm;dotx;h;hpp;htm;html;hxx;ini;java;lua;mht;mhtml;odt;pdf;potx;potm;ppam;ppsm;ppsx;pps;ppt;pptm;pptx;rtf;sldm;sldx;thmx;txt;vsd;wpd;wps;wri;xlam;xls;xlsb;xlsm;xlsx;xltm;xltx;xml report.doc")] 92 | public string Document(string search) 93 | { 94 | var queryable = this.everyThing 95 | .Search() 96 | .File 97 | .Document(search); 98 | 99 | return queryable.ToString(); 100 | } 101 | 102 | [TestCase("", ExpectedResult = "dupe:")] 103 | [TestCase(null, ExpectedResult = "dupe:")] 104 | [TestCase("main.cs", ExpectedResult = "dupe:main.cs")] 105 | public string Duplicates(string search) 106 | { 107 | var queryable = this.everyThing 108 | .Search() 109 | .File 110 | .Duplicates(search); 111 | 112 | return queryable.ToString(); 113 | } 114 | 115 | [Test] 116 | public void Roots() 117 | { 118 | var queryable = this.everyThing 119 | .Search() 120 | .File 121 | .Roots(); 122 | 123 | Assert.That(queryable.ToString(), Is.EqualTo("root:")); 124 | } 125 | 126 | [Test] 127 | public void AcceptanceTest() 128 | { 129 | var queryable = new Everything() 130 | .Search() 131 | .File.Exe(); 132 | 133 | Assert.That(queryable.Count, Is.GreaterThan(0)); 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /EverythingNet.Tests/EverythingNet.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {47039D9A-1F54-49D3-B19C-274840EEFDE6} 9 | Library 10 | Properties 11 | EverythingNet.Tests 12 | EverythingNet.Tests 13 | v4.6.2 14 | 512 15 | 16 | 17 | 18 | publish\ 19 | true 20 | Disk 21 | false 22 | Foreground 23 | 7 24 | Days 25 | false 26 | false 27 | true 28 | 0 29 | 1.0.0.%2a 30 | false 31 | false 32 | true 33 | 34 | 35 | true 36 | bin\x64\Debug\ 37 | DEBUG;TRACE 38 | full 39 | x64 40 | prompt 41 | MinimumRecommendedRules.ruleset 42 | 43 | 44 | bin\x64\Release\ 45 | TRACE 46 | true 47 | pdbonly 48 | x64 49 | prompt 50 | MinimumRecommendedRules.ruleset 51 | 52 | 53 | 54 | ..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | False 87 | Microsoft .NET Framework 4.6.2 %28x86 and x64%29 88 | true 89 | 90 | 91 | False 92 | .NET Framework 3.5 SP1 93 | false 94 | 95 | 96 | 97 | 98 | Everything.exe 99 | PreserveNewest 100 | 101 | 102 | Everything64.dll 103 | PreserveNewest 104 | 105 | 106 | 107 | 108 | {c6cc7352-f58b-4274-b629-a15a7f3c69cd} 109 | EverythingNet 110 | 111 | 112 | 113 | 114 | 115 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /EverythingNet.Tests/AcceptanceTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using EverythingNet.Core; 5 | using EverythingNet.Interfaces; 6 | using NUnit.Framework; 7 | 8 | namespace EverythingNet.Tests 9 | { 10 | using System.IO; 11 | using System.Linq; 12 | 13 | [TestFixture] 14 | public class AcceptanceTests 15 | { 16 | private const string FileToSearchA = "EverythingState.cs"; 17 | private const string FileToSearchB = "DateSearchTests.cs"; 18 | 19 | private Everything everyThing; 20 | 21 | [SetUp] 22 | public void Setup() 23 | { 24 | this.everyThing = new Everything(); 25 | } 26 | 27 | [TearDown] 28 | public void TearDown() 29 | { 30 | this.everyThing.Dispose(); 31 | } 32 | 33 | [Test] 34 | public void Query() 35 | { 36 | var queryable = new Everything() 37 | .Search() 38 | .Name.Contains(FileToSearchA) 39 | .Or 40 | .Name.Contains(FileToSearchB); 41 | 42 | Assert.That(queryable.Where(x => x.FileName == FileToSearchA), Is.Not.Empty); 43 | Assert.That(queryable.Where(x => x.FileName == FileToSearchB), Is.Not.Empty); 44 | } 45 | 46 | [Test] 47 | public void SearchGetSize() 48 | { 49 | var queryable = new Everything() 50 | .Search() 51 | .Name 52 | .Contains(FileToSearchA); 53 | 54 | foreach (var result in queryable) 55 | { 56 | Assert.That(result.Size, Is.GreaterThan(0)); 57 | } 58 | } 59 | 60 | [Test] 61 | public void SearchGetFileName() 62 | { 63 | var queryable = new Everything() 64 | .Search() 65 | .Name 66 | .Contains(FileToSearchA); 67 | 68 | foreach (var result in queryable) 69 | { 70 | Assert.That(result.FileName, Is.EqualTo(FileToSearchA)); 71 | } 72 | } 73 | 74 | [Test] 75 | public void SearchGetPath() 76 | { 77 | var queryable = new Everything() 78 | .Search() 79 | .Name 80 | .Contains(FileToSearchA); 81 | 82 | foreach (var result in queryable) 83 | { 84 | Assert.That(result.Path, Is.Not.Empty.And.Not.Null); 85 | } 86 | } 87 | 88 | [Test] 89 | public void SearchGetFullPath() 90 | { 91 | var queryable = new Everything() 92 | .Search() 93 | .Name 94 | .Contains(FileToSearchA); 95 | 96 | foreach (var result in queryable) 97 | { 98 | Assert.That(result.FullPath, Does.Contain($"EverythingNet\\core\\{FileToSearchA}").IgnoreCase); 99 | } 100 | } 101 | 102 | [Test] 103 | public void SearchGetDate() 104 | { 105 | var queryable = new Everything() 106 | .Search() 107 | .Name 108 | .Contains(FileToSearchA); 109 | 110 | foreach (var result in queryable) 111 | { 112 | Assert.That(result.Modified.Year, Is.GreaterThanOrEqualTo(2017)); 113 | } 114 | } 115 | 116 | [Test] 117 | public void SearchGetAttributes() 118 | { 119 | var queryable = new Everything() 120 | .Search() 121 | .Name 122 | .Contains(FileToSearchA); 123 | 124 | foreach (var result in queryable) 125 | { 126 | Assert.That(result.Attributes, Is.GreaterThan(0)); 127 | } 128 | } 129 | 130 | [Test] 131 | public void Zip_Succeeds() 132 | { 133 | // Arrange 134 | string zipFile = "acceptanceTest.zip"; 135 | File.Create(zipFile).Close(); 136 | Thread.Sleep(1000); 137 | 138 | var queryable = new Everything() 139 | .Search() 140 | .File 141 | .Zip(); 142 | 143 | // Assert 144 | Assert.That(queryable.Where(x => x.FileName == zipFile), Is.Not.Empty); 145 | 146 | File.Delete(zipFile); 147 | } 148 | 149 | [Test, Repeat(100)] 150 | public void StressTest() 151 | { 152 | // Arrange 153 | var queryable = this.everyThing 154 | .Search() 155 | .Name 156 | .Contains(FileToSearchA); 157 | 158 | // Assert 159 | Assert.That(this.everyThing.LastErrorCode, Is.EqualTo(ErrorCode.Ok)); 160 | Assert.That(queryable, Is.Not.Null); 161 | Assert.That(queryable, Is.Not.Empty); 162 | } 163 | 164 | 165 | [Test, Ignore("Not yet ready")] 166 | public void ThreadSafety() 167 | { 168 | ManualResetEventSlim resetEvent1 = this.StartSearchInBackground(FileToSearchA); 169 | ManualResetEventSlim resetEvent2 = this.StartSearchInBackground(FileToSearchB); 170 | 171 | Assert.That(resetEvent1.Wait(15000), Is.True); 172 | Assert.That(resetEvent2.Wait(15000), Is.True); 173 | } 174 | 175 | [Test] 176 | public void MultipleInstances() 177 | { 178 | var firstResult = this.everyThing 179 | .Search() 180 | .Name 181 | .Contains("IImageQueryable.cs"); 182 | 183 | IEverything secondEverything = new Everything(); 184 | var secondResult = secondEverything 185 | .Search() 186 | .Name 187 | .Contains("IMusicQueryable.cs"); 188 | 189 | Assert.That(firstResult.First().FileName, Is.EqualTo("IImageQueryable.cs")); 190 | Assert.That(secondResult.First().FileName, Is.EqualTo("IMusicQueryable.cs")); 191 | 192 | } 193 | 194 | [Test] 195 | public void CountPerformance() 196 | { 197 | var queryable = new Everything() 198 | .Search() 199 | .Name.Contains("micro"); 200 | 201 | Assert.That(queryable.Count, Is.GreaterThan(0)); 202 | } 203 | 204 | private ManualResetEventSlim StartSearchInBackground(string searchString) 205 | { 206 | ManualResetEventSlim resetEvent = new ManualResetEventSlim(false); 207 | 208 | Task.Factory.StartNew(() => 209 | { 210 | IEverything everything = new Everything(); 211 | everything.MatchWholeWord = true; 212 | 213 | // Act 214 | var results = everything 215 | .Search() 216 | .Name 217 | .Contains(searchString); 218 | 219 | // Assert 220 | Assert.That(this.everyThing.LastErrorCode, Is.EqualTo(ErrorCode.Ok)); 221 | Assert.That(results, Is.Not.Empty); 222 | foreach (var result in results) 223 | { 224 | StringAssert.Contains(searchString, result.FileName); 225 | } 226 | resetEvent.Set(); 227 | }); 228 | 229 | return resetEvent; 230 | } 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /EverythingNet/Core/EverythingWrapper.cs: -------------------------------------------------------------------------------- 1 | namespace EverythingNet.Core 2 | { 3 | using System; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading; 7 | 8 | internal class EverythingWrapper 9 | { 10 | private static readonly ReaderWriterLockSlim locker = new ReaderWriterLockSlim(); 11 | 12 | private class Locker : IDisposable 13 | { 14 | private readonly ReaderWriterLockSlim locker; 15 | 16 | public Locker(ReaderWriterLockSlim locker) 17 | { 18 | this.locker = locker; 19 | this.locker.EnterWriteLock(); 20 | } 21 | 22 | public void Dispose() 23 | { 24 | this.locker.ExitWriteLock(); 25 | } 26 | } 27 | 28 | #if WIN32 29 | private const string EverythingDLL = EverythingDLL; 30 | #else 31 | private const string EverythingDLL = "Everything64.dll"; 32 | #endif 33 | 34 | private const int EVERYTHING_OK = 0; 35 | private const int EVERYTHING_ERROR_MEMORY = 1; 36 | private const int EVERYTHING_ERROR_IPC = 2; 37 | private const int EVERYTHING_ERROR_REGISTERCLASSEX = 3; 38 | private const int EVERYTHING_ERROR_CREATEWINDOW = 4; 39 | private const int EVERYTHING_ERROR_CREATETHREAD = 5; 40 | private const int EVERYTHING_ERROR_INVALIDINDEX = 6; 41 | private const int EVERYTHING_ERROR_INVALIDCALL = 7; 42 | 43 | public enum FileInfoIndex 44 | { 45 | FileSize = 1, 46 | FolderSize, 47 | DateCreated, 48 | DateModified, 49 | DateAccessed, 50 | Attributes 51 | } 52 | 53 | 54 | internal static IDisposable Lock() 55 | { 56 | return new Locker(locker); 57 | } 58 | 59 | [DllImport(EverythingDLL)] 60 | public static extern bool Everything_IsDBLoaded(); 61 | 62 | [DllImport(EverythingDLL)] 63 | public static extern UInt32 Everything_GetMajorVersion(); 64 | 65 | [DllImport(EverythingDLL)] 66 | public static extern UInt32 Everything_GetMinorVersion(); 67 | 68 | [DllImport(EverythingDLL)] 69 | public static extern UInt32 Everything_GetRevision(); 70 | 71 | [DllImport(EverythingDLL)] 72 | public static extern UInt32 Everything_GetBuildNumber(); 73 | 74 | [DllImport(EverythingDLL)] 75 | public static extern int Everything_SetSearch(string lpSearchString); 76 | 77 | [DllImport(EverythingDLL)] 78 | public static extern void Everything_SetMatchPath(bool bEnable); 79 | 80 | [DllImport(EverythingDLL)] 81 | public static extern void Everything_SetMatchCase(bool bEnable); 82 | 83 | [DllImport(EverythingDLL)] 84 | public static extern void Everything_SetMatchWholeWord(bool bEnable); 85 | 86 | [DllImport(EverythingDLL)] 87 | public static extern void Everything_SetRegex(bool bEnable); 88 | 89 | [DllImport(EverythingDLL)] 90 | public static extern void Everything_SetMax(UInt32 dwMax); 91 | 92 | [DllImport(EverythingDLL)] 93 | public static extern void Everything_SetOffset(UInt32 dwOffset); 94 | 95 | [DllImport(EverythingDLL)] 96 | public static extern void Everything_SetReplyWindow(IntPtr handler); 97 | 98 | [DllImport(EverythingDLL)] 99 | public static extern void Everything_SetReplyID(UInt32 nId); 100 | 101 | [DllImport(EverythingDLL)] 102 | public static extern void Everything_Reset(); 103 | 104 | [DllImport(EverythingDLL)] 105 | public static extern bool Everything_GetMatchPath(); 106 | 107 | [DllImport(EverythingDLL)] 108 | public static extern bool Everything_GetMatchCase(); 109 | 110 | [DllImport(EverythingDLL)] 111 | public static extern bool Everything_GetMatchWholeWord(); 112 | 113 | [DllImport(EverythingDLL)] 114 | public static extern bool Everything_GetRegex(); 115 | 116 | [DllImport(EverythingDLL)] 117 | public static extern UInt32 Everything_GetMax(); 118 | 119 | [DllImport(EverythingDLL)] 120 | public static extern UInt32 Everything_GetOffset(); 121 | 122 | [DllImport(EverythingDLL)] 123 | public static extern IntPtr Everything_GetSearch(); 124 | 125 | [DllImport(EverythingDLL)] 126 | public static extern int Everything_GetLastError(); 127 | 128 | [DllImport(EverythingDLL)] 129 | public static extern bool Everything_Query(bool bWait); 130 | 131 | [DllImport(EverythingDLL)] 132 | public static extern void Everything_SortResultsByPath(); 133 | 134 | [DllImport(EverythingDLL)] 135 | public static extern UInt32 Everything_GetNumFileResults(); 136 | 137 | [DllImport(EverythingDLL)] 138 | public static extern UInt32 Everything_GetNumFolderResults(); 139 | 140 | [DllImport(EverythingDLL)] 141 | public static extern UInt32 Everything_GetNumResults(); 142 | 143 | [DllImport(EverythingDLL)] 144 | public static extern UInt32 Everything_GetTotFileResults(); 145 | 146 | [DllImport(EverythingDLL)] 147 | public static extern UInt32 Everything_GetTotFolderResults(); 148 | 149 | [DllImport(EverythingDLL)] 150 | public static extern UInt32 Everything_GetTotResults(); 151 | 152 | [DllImport(EverythingDLL)] 153 | public static extern bool Everything_IsVolumeResult(UInt32 nIndex); 154 | 155 | [DllImport(EverythingDLL)] 156 | public static extern bool Everything_IsFolderResult(UInt32 nIndex); 157 | 158 | [DllImport(EverythingDLL)] 159 | public static extern bool Everything_IsFileResult(UInt32 nIndex); 160 | 161 | [DllImport(EverythingDLL, CharSet = CharSet.Unicode)] 162 | public static extern void Everything_GetResultFullPathName(UInt32 nIndex, StringBuilder lpString, UInt32 nMaxCount); 163 | 164 | // Everything 1.4 165 | [DllImport(EverythingDLL)] 166 | public static extern void Everything_SetSort(UInt32 dwSortType); 167 | 168 | 169 | [DllImport(EverythingDLL)] 170 | public static extern UInt32 Everything_GetSort(); 171 | 172 | [DllImport(EverythingDLL)] 173 | public static extern UInt32 Everything_GetResultListSort(); 174 | 175 | [DllImport(EverythingDLL)] 176 | public static extern void Everything_SetRequestFlags(UInt32 dwRequestFlags); 177 | 178 | [DllImport(EverythingDLL)] 179 | public static extern UInt32 Everything_GetRequestFlags(); 180 | 181 | [DllImport(EverythingDLL)] 182 | public static extern UInt32 Everything_GetResultListRequestFlags(); 183 | 184 | [DllImport(EverythingDLL, CharSet = CharSet.Unicode)] 185 | public static extern string Everything_GetResultExtension(UInt32 nIndex); 186 | 187 | [DllImport(EverythingDLL)] 188 | public static extern bool Everything_GetResultSize(UInt32 nIndex, out long lpFileSize); 189 | 190 | [DllImport(EverythingDLL)] 191 | public static extern bool Everything_GetResultDateCreated(UInt32 nIndex, out long lpFileTime); 192 | 193 | [DllImport(EverythingDLL)] 194 | public static extern bool Everything_GetResultDateModified(UInt32 nIndex, out long lpFileTime); 195 | 196 | [DllImport(EverythingDLL)] 197 | public static extern bool Everything_GetResultDateAccessed(UInt32 nIndex, out long lpFileTime); 198 | 199 | [DllImport(EverythingDLL)] 200 | public static extern UInt32 Everything_GetResultAttributes(UInt32 nIndex); 201 | 202 | [DllImport(EverythingDLL, CharSet = CharSet.Unicode)] 203 | public static extern string Everything_GetResultFileListFileName(UInt32 nIndex); 204 | 205 | [DllImport(EverythingDLL, CharSet = CharSet.Unicode)] 206 | public static extern string Everything_GetResultPath(UInt32 nIndex); 207 | 208 | [DllImport(EverythingDLL, CharSet = CharSet.Unicode)] 209 | public static extern string Everything_GetResultFileName(UInt32 nIndex); 210 | 211 | [DllImport(EverythingDLL)] 212 | public static extern UInt32 Everything_GetResultRunCount(UInt32 nIndex); 213 | 214 | [DllImport(EverythingDLL)] 215 | public static extern bool Everything_GetResultDateRun(UInt32 nIndex, out long lpFileTime); 216 | 217 | [DllImport(EverythingDLL)] 218 | public static extern bool Everything_GetResultDateRecentlyChanged(UInt32 nIndex, out long lpFileTime); 219 | 220 | [DllImport(EverythingDLL, CharSet = CharSet.Unicode)] 221 | public static extern string Everything_GetResultHighlightedFileName(UInt32 nIndex); 222 | 223 | [DllImport(EverythingDLL, CharSet = CharSet.Unicode)] 224 | public static extern string Everything_GetResultHighlightedPath(UInt32 nIndex); 225 | 226 | [DllImport(EverythingDLL, CharSet = CharSet.Unicode)] 227 | public static extern string Everything_GetResultHighlightedFullPathAndFileName(UInt32 nIndex); 228 | 229 | [DllImport(EverythingDLL)] 230 | public static extern UInt32 Everything_GetRunCountFromFileName(string lpFileName); 231 | 232 | [DllImport(EverythingDLL)] 233 | public static extern bool Everything_SetRunCountFromFileName(string lpFileName, UInt32 dwRunCount); 234 | 235 | [DllImport(EverythingDLL)] 236 | public static extern UInt32 Everything_IncRunCountFromFileName(string lpFileName); 237 | 238 | [DllImport(EverythingDLL)] 239 | public static extern bool Everything_IsFileInfoIndexed(FileInfoIndex fileInfoType); 240 | } 241 | } -------------------------------------------------------------------------------- /EverythingNet.Bench/EverythingNet.Bench.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D077C127-1161-41F5-BC74-FBDCCE294812} 8 | Exe 9 | EverythingNet.Bench 10 | EverythingNet.Bench 11 | v4.6.2 12 | 512 13 | true 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | false 35 | 36 | 37 | 38 | ..\packages\BenchmarkDotNet.0.10.9\lib\net46\BenchmarkDotNet.dll 39 | 40 | 41 | ..\packages\BenchmarkDotNet.Core.0.10.9\lib\net46\BenchmarkDotNet.Core.dll 42 | 43 | 44 | ..\packages\BenchmarkDotNet.Toolchains.Roslyn.0.10.9\lib\net46\BenchmarkDotNet.Toolchains.Roslyn.dll 45 | 46 | 47 | ..\packages\Microsoft.CodeAnalysis.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll 48 | 49 | 50 | ..\packages\Microsoft.CodeAnalysis.CSharp.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll 51 | 52 | 53 | ..\packages\Microsoft.DotNet.InternalAbstractions.1.0.0\lib\net451\Microsoft.DotNet.InternalAbstractions.dll 54 | 55 | 56 | ..\packages\Microsoft.DotNet.PlatformAbstractions.1.1.1\lib\net451\Microsoft.DotNet.PlatformAbstractions.dll 57 | 58 | 59 | ..\packages\Microsoft.Win32.Registry.4.3.0\lib\net46\Microsoft.Win32.Registry.dll 60 | 61 | 62 | 63 | ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll 64 | 65 | 66 | ..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 67 | True 68 | 69 | 70 | 71 | ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll 72 | 73 | 74 | 75 | ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll 76 | 77 | 78 | ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll 79 | 80 | 81 | ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll 82 | True 83 | 84 | 85 | ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll 86 | 87 | 88 | ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll 89 | 90 | 91 | 92 | ..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll 93 | 94 | 95 | ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll 96 | 97 | 98 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll 99 | 100 | 101 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll 102 | 103 | 104 | ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll 105 | 106 | 107 | ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll 108 | 109 | 110 | ..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll 111 | 112 | 113 | ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll 114 | 115 | 116 | ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll 126 | 127 | 128 | ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll 129 | 130 | 131 | ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll 132 | 133 | 134 | ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | {c6cc7352-f58b-4274-b629-a15a7f3c69cd} 154 | EverythingNet 155 | 156 | 157 | 158 | 159 | Everything.exe 160 | PreserveNewest 161 | 162 | 163 | Everything64.dll 164 | PreserveNewest 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /EverythingNet.Tests/DateSearchTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using EverythingNet.Core; 3 | using EverythingNet.Interfaces; 4 | using NUnit.Framework; 5 | 6 | namespace EverythingNet.Tests 7 | { 8 | [TestFixture] 9 | public class DateSearchTests 10 | { 11 | private Everything everyThing; 12 | 13 | [SetUp] 14 | public void Setup() 15 | { 16 | this.everyThing = new Everything(); 17 | } 18 | 19 | [TearDown] 20 | public void TearDown() 21 | { 22 | this.everyThing.Dispose(); 23 | } 24 | 25 | [Test, Ignore("Too long to execute")] 26 | public void CreationDate() 27 | { 28 | // Arrange 29 | string filename = "FileCreatedToday.txt"; 30 | using (File.Create(filename)) {} 31 | string expectedResult = Path.Combine(Directory.GetCurrentDirectory(), filename); 32 | 33 | // Act 34 | var results = this.everyThing.Search() 35 | .CreationDate 36 | .Equal(Dates.Today); 37 | 38 | // Assert 39 | Assert.That(this.everyThing.LastErrorCode, Is.EqualTo(ErrorCode.Ok)); 40 | Assert.That(results, Has.Member(expectedResult)); 41 | } 42 | [TestCase(Dates.Yesterday, ExpectedResult = "da:yesterday")] 43 | [TestCase(Dates.Today, ExpectedResult = "da:today")] 44 | [TestCase(Dates.LastYear, ExpectedResult = "da:lastyear")] 45 | [TestCase(Dates.LastMonth, ExpectedResult = "da:lastmonth")] 46 | [TestCase(Dates.LastWeek, ExpectedResult = "da:lastweek")] 47 | [TestCase(Dates.ThisYear, ExpectedResult = "da:thisyear")] 48 | [TestCase(Dates.ThisMonth, ExpectedResult = "da:thismonth")] 49 | [TestCase(Dates.ThisWeek, ExpectedResult = "da:thisweek")] 50 | [TestCase(Dates.NextYear, ExpectedResult = "da:nextyear")] 51 | [TestCase(Dates.NextMonth, ExpectedResult = "da:nextmonth")] 52 | [TestCase(Dates.NextWeek, ExpectedResult = "da:nextweek")] 53 | [TestCase(Dates.LastJanuary, ExpectedResult = "da:lastjanuary")] 54 | [TestCase(Dates.LastFebuary, ExpectedResult = "da:lastfebuary")] 55 | [TestCase(Dates.LastMarch, ExpectedResult = "da:lastmarch")] 56 | [TestCase(Dates.LastApril, ExpectedResult = "da:lastapril")] 57 | [TestCase(Dates.LastMay, ExpectedResult = "da:lastmay")] 58 | [TestCase(Dates.LastJune, ExpectedResult = "da:lastjune")] 59 | [TestCase(Dates.LastJuly, ExpectedResult = "da:lastjuly")] 60 | [TestCase(Dates.LastAugust, ExpectedResult = "da:lastaugust")] 61 | [TestCase(Dates.LastSeptember, ExpectedResult = "da:lastseptember")] 62 | [TestCase(Dates.LastOctober, ExpectedResult = "da:lastoctober")] 63 | [TestCase(Dates.LastNovember, ExpectedResult = "da:lastnovember")] 64 | [TestCase(Dates.LastDecember, ExpectedResult = "da:lastdecember")] 65 | [TestCase(Dates.ThisJanuary, ExpectedResult = "da:thisjanuary")] 66 | [TestCase(Dates.ThisFebuary, ExpectedResult = "da:thisfebuary")] 67 | [TestCase(Dates.ThisMarch, ExpectedResult = "da:thismarch")] 68 | [TestCase(Dates.ThisApril, ExpectedResult = "da:thisapril")] 69 | [TestCase(Dates.ThisMay, ExpectedResult = "da:thismay")] 70 | [TestCase(Dates.ThisJune, ExpectedResult = "da:thisjune")] 71 | [TestCase(Dates.ThisJuly, ExpectedResult = "da:thisjuly")] 72 | [TestCase(Dates.ThisAugust, ExpectedResult = "da:thisaugust")] 73 | [TestCase(Dates.ThisSeptember, ExpectedResult = "da:thisseptember")] 74 | [TestCase(Dates.ThisOctober, ExpectedResult = "da:thisoctober")] 75 | [TestCase(Dates.ThisNovember, ExpectedResult = "da:thisnovember")] 76 | [TestCase(Dates.ThisDecember, ExpectedResult = "da:thisdecember")] 77 | [TestCase(Dates.LastSunday, ExpectedResult = "da:lastsunday")] 78 | [TestCase(Dates.LastMonday, ExpectedResult = "da:lastmonday")] 79 | [TestCase(Dates.LastTuesday, ExpectedResult = "da:lasttuesday")] 80 | [TestCase(Dates.LastWednesday, ExpectedResult = "da:lastwednesday")] 81 | [TestCase(Dates.LastThursday, ExpectedResult = "da:lastthursday")] 82 | [TestCase(Dates.LastFriday, ExpectedResult = "da:lastfriday")] 83 | [TestCase(Dates.LastSaturday, ExpectedResult = "da:lastsaturday")] 84 | [TestCase(Dates.ThisSunday, ExpectedResult = "da:thissunday")] 85 | [TestCase(Dates.ThisMonday, ExpectedResult = "da:thismonday")] 86 | [TestCase(Dates.ThisTuesday, ExpectedResult = "da:thistuesday")] 87 | [TestCase(Dates.ThisWednesday, ExpectedResult = "da:thiswednesday")] 88 | [TestCase(Dates.ThisThursday, ExpectedResult = "da:thisthursday")] 89 | [TestCase(Dates.ThisFriday, ExpectedResult = "da:thisfriday")] 90 | [TestCase(Dates.ThisSaturday, ExpectedResult = "da:thissaturday")] 91 | public string AccessDate(Dates date) 92 | { 93 | // Act 94 | var queryable = this.everyThing 95 | .Search() 96 | .AccessDate 97 | .Equal(date); 98 | 99 | // Assert 100 | return queryable.ToString().ToLower(); 101 | } 102 | 103 | [TestCase(Dates.Yesterday, ExpectedResult = "dm:yesterday")] 104 | [TestCase(Dates.Today, ExpectedResult = "dm:today")] 105 | [TestCase(Dates.LastYear, ExpectedResult = "dm:lastyear")] 106 | [TestCase(Dates.LastMonth, ExpectedResult = "dm:lastmonth")] 107 | [TestCase(Dates.LastWeek, ExpectedResult = "dm:lastweek")] 108 | [TestCase(Dates.ThisYear, ExpectedResult = "dm:thisyear")] 109 | [TestCase(Dates.ThisMonth, ExpectedResult = "dm:thismonth")] 110 | [TestCase(Dates.ThisWeek, ExpectedResult = "dm:thisweek")] 111 | [TestCase(Dates.NextYear, ExpectedResult = "dm:nextyear")] 112 | [TestCase(Dates.NextMonth, ExpectedResult = "dm:nextmonth")] 113 | [TestCase(Dates.NextWeek, ExpectedResult = "dm:nextweek")] 114 | [TestCase(Dates.LastJanuary, ExpectedResult = "dm:lastjanuary")] 115 | [TestCase(Dates.LastFebuary, ExpectedResult = "dm:lastfebuary")] 116 | [TestCase(Dates.LastMarch, ExpectedResult = "dm:lastmarch")] 117 | [TestCase(Dates.LastApril, ExpectedResult = "dm:lastapril")] 118 | [TestCase(Dates.LastMay, ExpectedResult = "dm:lastmay")] 119 | [TestCase(Dates.LastJune, ExpectedResult = "dm:lastjune")] 120 | [TestCase(Dates.LastJuly, ExpectedResult = "dm:lastjuly")] 121 | [TestCase(Dates.LastAugust, ExpectedResult = "dm:lastaugust")] 122 | [TestCase(Dates.LastSeptember, ExpectedResult = "dm:lastseptember")] 123 | [TestCase(Dates.LastOctober, ExpectedResult = "dm:lastoctober")] 124 | [TestCase(Dates.LastNovember, ExpectedResult = "dm:lastnovember")] 125 | [TestCase(Dates.LastDecember, ExpectedResult = "dm:lastdecember")] 126 | [TestCase(Dates.ThisJanuary, ExpectedResult = "dm:thisjanuary")] 127 | [TestCase(Dates.ThisFebuary, ExpectedResult = "dm:thisfebuary")] 128 | [TestCase(Dates.ThisMarch, ExpectedResult = "dm:thismarch")] 129 | [TestCase(Dates.ThisApril, ExpectedResult = "dm:thisapril")] 130 | [TestCase(Dates.ThisMay, ExpectedResult = "dm:thismay")] 131 | [TestCase(Dates.ThisJune, ExpectedResult = "dm:thisjune")] 132 | [TestCase(Dates.ThisJuly, ExpectedResult = "dm:thisjuly")] 133 | [TestCase(Dates.ThisAugust, ExpectedResult = "dm:thisaugust")] 134 | [TestCase(Dates.ThisSeptember, ExpectedResult = "dm:thisseptember")] 135 | [TestCase(Dates.ThisOctober, ExpectedResult = "dm:thisoctober")] 136 | [TestCase(Dates.ThisNovember, ExpectedResult = "dm:thisnovember")] 137 | [TestCase(Dates.ThisDecember, ExpectedResult = "dm:thisdecember")] 138 | [TestCase(Dates.LastSunday, ExpectedResult = "dm:lastsunday")] 139 | [TestCase(Dates.LastMonday, ExpectedResult = "dm:lastmonday")] 140 | [TestCase(Dates.LastTuesday, ExpectedResult = "dm:lasttuesday")] 141 | [TestCase(Dates.LastWednesday, ExpectedResult = "dm:lastwednesday")] 142 | [TestCase(Dates.LastThursday, ExpectedResult = "dm:lastthursday")] 143 | [TestCase(Dates.LastFriday, ExpectedResult = "dm:lastfriday")] 144 | [TestCase(Dates.LastSaturday, ExpectedResult = "dm:lastsaturday")] 145 | [TestCase(Dates.ThisSunday, ExpectedResult = "dm:thissunday")] 146 | [TestCase(Dates.ThisMonday, ExpectedResult = "dm:thismonday")] 147 | [TestCase(Dates.ThisTuesday, ExpectedResult = "dm:thistuesday")] 148 | [TestCase(Dates.ThisWednesday, ExpectedResult = "dm:thiswednesday")] 149 | [TestCase(Dates.ThisThursday, ExpectedResult = "dm:thisthursday")] 150 | [TestCase(Dates.ThisFriday, ExpectedResult = "dm:thisfriday")] 151 | [TestCase(Dates.ThisSaturday, ExpectedResult = "dm:thissaturday")] 152 | public string ModificationDate(Dates date) 153 | { 154 | // Act 155 | var queryable = this.everyThing 156 | .Search() 157 | .ModificationDate 158 | .Equal(date); 159 | 160 | // Assert 161 | return queryable.ToString().ToLower(); 162 | } 163 | 164 | 165 | [TestCase(Dates.Yesterday, ExpectedResult = "dc:yesterday")] 166 | [TestCase(Dates.Today, ExpectedResult = "dc:today")] 167 | [TestCase(Dates.LastYear, ExpectedResult = "dc:lastyear")] 168 | [TestCase(Dates.LastMonth, ExpectedResult = "dc:lastmonth")] 169 | [TestCase(Dates.LastWeek, ExpectedResult = "dc:lastweek")] 170 | [TestCase(Dates.ThisYear, ExpectedResult = "dc:thisyear")] 171 | [TestCase(Dates.ThisMonth, ExpectedResult = "dc:thismonth")] 172 | [TestCase(Dates.ThisWeek, ExpectedResult = "dc:thisweek")] 173 | [TestCase(Dates.NextYear, ExpectedResult = "dc:nextyear")] 174 | [TestCase(Dates.NextMonth, ExpectedResult = "dc:nextmonth")] 175 | [TestCase(Dates.NextWeek, ExpectedResult = "dc:nextweek")] 176 | [TestCase(Dates.LastJanuary, ExpectedResult = "dc:lastjanuary")] 177 | [TestCase(Dates.LastFebuary, ExpectedResult = "dc:lastfebuary")] 178 | [TestCase(Dates.LastMarch, ExpectedResult = "dc:lastmarch")] 179 | [TestCase(Dates.LastApril, ExpectedResult = "dc:lastapril")] 180 | [TestCase(Dates.LastMay, ExpectedResult = "dc:lastmay")] 181 | [TestCase(Dates.LastJune, ExpectedResult = "dc:lastjune")] 182 | [TestCase(Dates.LastJuly, ExpectedResult = "dc:lastjuly")] 183 | [TestCase(Dates.LastAugust, ExpectedResult = "dc:lastaugust")] 184 | [TestCase(Dates.LastSeptember, ExpectedResult = "dc:lastseptember")] 185 | [TestCase(Dates.LastOctober, ExpectedResult = "dc:lastoctober")] 186 | [TestCase(Dates.LastNovember, ExpectedResult = "dc:lastnovember")] 187 | [TestCase(Dates.LastDecember, ExpectedResult = "dc:lastdecember")] 188 | [TestCase(Dates.ThisJanuary, ExpectedResult = "dc:thisjanuary")] 189 | [TestCase(Dates.ThisFebuary, ExpectedResult = "dc:thisfebuary")] 190 | [TestCase(Dates.ThisMarch, ExpectedResult = "dc:thismarch")] 191 | [TestCase(Dates.ThisApril, ExpectedResult = "dc:thisapril")] 192 | [TestCase(Dates.ThisMay, ExpectedResult = "dc:thismay")] 193 | [TestCase(Dates.ThisJune, ExpectedResult = "dc:thisjune")] 194 | [TestCase(Dates.ThisJuly, ExpectedResult = "dc:thisjuly")] 195 | [TestCase(Dates.ThisAugust, ExpectedResult = "dc:thisaugust")] 196 | [TestCase(Dates.ThisSeptember, ExpectedResult = "dc:thisseptember")] 197 | [TestCase(Dates.ThisOctober, ExpectedResult = "dc:thisoctober")] 198 | [TestCase(Dates.ThisNovember, ExpectedResult = "dc:thisnovember")] 199 | [TestCase(Dates.ThisDecember, ExpectedResult = "dc:thisdecember")] 200 | [TestCase(Dates.LastSunday, ExpectedResult = "dc:lastsunday")] 201 | [TestCase(Dates.LastMonday, ExpectedResult = "dc:lastmonday")] 202 | [TestCase(Dates.LastTuesday, ExpectedResult = "dc:lasttuesday")] 203 | [TestCase(Dates.LastWednesday, ExpectedResult = "dc:lastwednesday")] 204 | [TestCase(Dates.LastThursday, ExpectedResult = "dc:lastthursday")] 205 | [TestCase(Dates.LastFriday, ExpectedResult = "dc:lastfriday")] 206 | [TestCase(Dates.LastSaturday, ExpectedResult = "dc:lastsaturday")] 207 | [TestCase(Dates.ThisSunday, ExpectedResult = "dc:thissunday")] 208 | [TestCase(Dates.ThisMonday, ExpectedResult = "dc:thismonday")] 209 | [TestCase(Dates.ThisTuesday, ExpectedResult = "dc:thistuesday")] 210 | [TestCase(Dates.ThisWednesday, ExpectedResult = "dc:thiswednesday")] 211 | [TestCase(Dates.ThisThursday, ExpectedResult = "dc:thisthursday")] 212 | [TestCase(Dates.ThisFriday, ExpectedResult = "dc:thisfriday")] 213 | [TestCase(Dates.ThisSaturday, ExpectedResult = "dc:thissaturday")] 214 | public string CreationDate(Dates date) 215 | { 216 | // Act 217 | var queryable = this.everyThing 218 | .Search() 219 | .CreationDate 220 | .Equal(date); 221 | 222 | // Assert 223 | return queryable.ToString().ToLower(); 224 | } 225 | 226 | 227 | [TestCase(Dates.Yesterday, ExpectedResult = "dr:yesterday")] 228 | [TestCase(Dates.Today, ExpectedResult = "dr:today")] 229 | [TestCase(Dates.LastYear, ExpectedResult = "dr:lastyear")] 230 | [TestCase(Dates.LastMonth, ExpectedResult = "dr:lastmonth")] 231 | [TestCase(Dates.LastWeek, ExpectedResult = "dr:lastweek")] 232 | [TestCase(Dates.ThisYear, ExpectedResult = "dr:thisyear")] 233 | [TestCase(Dates.ThisMonth, ExpectedResult = "dr:thismonth")] 234 | [TestCase(Dates.ThisWeek, ExpectedResult = "dr:thisweek")] 235 | [TestCase(Dates.NextYear, ExpectedResult = "dr:nextyear")] 236 | [TestCase(Dates.NextMonth, ExpectedResult = "dr:nextmonth")] 237 | [TestCase(Dates.NextWeek, ExpectedResult = "dr:nextweek")] 238 | [TestCase(Dates.LastJanuary, ExpectedResult = "dr:lastjanuary")] 239 | [TestCase(Dates.LastFebuary, ExpectedResult = "dr:lastfebuary")] 240 | [TestCase(Dates.LastMarch, ExpectedResult = "dr:lastmarch")] 241 | [TestCase(Dates.LastApril, ExpectedResult = "dr:lastapril")] 242 | [TestCase(Dates.LastMay, ExpectedResult = "dr:lastmay")] 243 | [TestCase(Dates.LastJune, ExpectedResult = "dr:lastjune")] 244 | [TestCase(Dates.LastJuly, ExpectedResult = "dr:lastjuly")] 245 | [TestCase(Dates.LastAugust, ExpectedResult = "dr:lastaugust")] 246 | [TestCase(Dates.LastSeptember, ExpectedResult = "dr:lastseptember")] 247 | [TestCase(Dates.LastOctober, ExpectedResult = "dr:lastoctober")] 248 | [TestCase(Dates.LastNovember, ExpectedResult = "dr:lastnovember")] 249 | [TestCase(Dates.LastDecember, ExpectedResult = "dr:lastdecember")] 250 | [TestCase(Dates.ThisJanuary, ExpectedResult = "dr:thisjanuary")] 251 | [TestCase(Dates.ThisFebuary, ExpectedResult = "dr:thisfebuary")] 252 | [TestCase(Dates.ThisMarch, ExpectedResult = "dr:thismarch")] 253 | [TestCase(Dates.ThisApril, ExpectedResult = "dr:thisapril")] 254 | [TestCase(Dates.ThisMay, ExpectedResult = "dr:thismay")] 255 | [TestCase(Dates.ThisJune, ExpectedResult = "dr:thisjune")] 256 | [TestCase(Dates.ThisJuly, ExpectedResult = "dr:thisjuly")] 257 | [TestCase(Dates.ThisAugust, ExpectedResult = "dr:thisaugust")] 258 | [TestCase(Dates.ThisSeptember, ExpectedResult = "dr:thisseptember")] 259 | [TestCase(Dates.ThisOctober, ExpectedResult = "dr:thisoctober")] 260 | [TestCase(Dates.ThisNovember, ExpectedResult = "dr:thisnovember")] 261 | [TestCase(Dates.ThisDecember, ExpectedResult = "dr:thisdecember")] 262 | [TestCase(Dates.LastSunday, ExpectedResult = "dr:lastsunday")] 263 | [TestCase(Dates.LastMonday, ExpectedResult = "dr:lastmonday")] 264 | [TestCase(Dates.LastTuesday, ExpectedResult = "dr:lasttuesday")] 265 | [TestCase(Dates.LastWednesday, ExpectedResult = "dr:lastwednesday")] 266 | [TestCase(Dates.LastThursday, ExpectedResult = "dr:lastthursday")] 267 | [TestCase(Dates.LastFriday, ExpectedResult = "dr:lastfriday")] 268 | [TestCase(Dates.LastSaturday, ExpectedResult = "dr:lastsaturday")] 269 | [TestCase(Dates.ThisSunday, ExpectedResult = "dr:thissunday")] 270 | [TestCase(Dates.ThisMonday, ExpectedResult = "dr:thismonday")] 271 | [TestCase(Dates.ThisTuesday, ExpectedResult = "dr:thistuesday")] 272 | [TestCase(Dates.ThisWednesday, ExpectedResult = "dr:thiswednesday")] 273 | [TestCase(Dates.ThisThursday, ExpectedResult = "dr:thisthursday")] 274 | [TestCase(Dates.ThisFriday, ExpectedResult = "dr:thisfriday")] 275 | [TestCase(Dates.ThisSaturday, ExpectedResult = "dr:thissaturday")] 276 | public string RunDate(Dates date) 277 | { 278 | // Act 279 | var queryable = this.everyThing 280 | .Search() 281 | .RunDate 282 | .Equal(date); 283 | 284 | // Assert 285 | return queryable.ToString().ToLower(); 286 | } 287 | 288 | [TestCase(1, CountableDates.Hours, ExpectedResult = "dm:last1hours")] 289 | [TestCase(2, CountableDates.Minutes, ExpectedResult = "dm:last2minutes")] 290 | [TestCase(3, CountableDates.Seconds, ExpectedResult = "dm:last3seconds")] 291 | [TestCase(4, CountableDates.Weeks, ExpectedResult = "dm:last4weeks")] 292 | [TestCase(5, CountableDates.Months, ExpectedResult = "dm:last5months")] 293 | [TestCase(6, CountableDates.Years, ExpectedResult = "dm:last6years")] 294 | public string LastDate(int count, CountableDates date) 295 | { 296 | // Act 297 | var queryable = this.everyThing 298 | .Search() 299 | .ModificationDate 300 | .Last(count, date); 301 | 302 | // Assert 303 | return queryable.ToString().ToLower(); 304 | } 305 | } 306 | } 307 | -------------------------------------------------------------------------------- /EverythingNet/EverythingNet.R#Settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | False 9 | 1 10 | 1 11 | 1 12 | SEPARATE 13 | ALWAYS_ADD 14 | ALWAYS_ADD 15 | ALWAYS_ADD 16 | ALWAYS_ADD 17 | False 18 | False 19 | 1 20 | 1 21 | False 22 | 23 | public 24 | protected 25 | internal 26 | private 27 | new 28 | abstract 29 | virtual 30 | override 31 | sealed 32 | static 33 | readonly 34 | extern 35 | unsafe 36 | volatile 37 | 38 | False 39 | False 40 | False 41 | False 42 | True 43 | ALWAYS_USE 44 | ON_SINGLE_LINE 45 | False 46 | True 47 | False 48 | False 49 | True 50 | False 51 | True 52 | True 53 | CHOP_IF_LONG 54 | True 55 | CHOP_IF_LONG 56 | 180 57 | CHOP_IF_LONG 58 | 59 | 60 | True 61 | True 62 | 63 | 64 | $object$_On$event$ 65 | $event$Handler 66 | 67 | 68 | True 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | ]]> 352 | 353 | 354 | 355 | 356 | 357 | $object$_On$event$ 358 | $event$Handler 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | $object$_On$event$ 377 | $event$Handler 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | False 400 | 401 | 402 | ]]> 403 | 404 | 405 | 406 | WARNING 407 | WARNING 408 | WARNING 409 | ERROR 410 | WARNING 411 | WARNING 412 | WARNING 413 | WARNING 414 | ERROR 415 | WARNING 416 | WARNING 417 | WARNING 418 | WARNING 419 | WARNING 420 | SUGGESTION 421 | HINT 422 | SUGGESTION 423 | WARNING 424 | SUGGESTION 425 | WARNING 426 | SUGGESTION 427 | WARNING 428 | SUGGESTION 429 | WARNING 430 | SUGGESTION 431 | WARNING 432 | WARNING 433 | WARNING 434 | WARNING 435 | WARNING 436 | WARNING 437 | WARNING 438 | WARNING 439 | WARNING 440 | WARNING 441 | WARNING 442 | WARNING 443 | WARNING 444 | SUGGESTION 445 | WARNING 446 | SUGGESTION 447 | WARNING 448 | SUGGESTION 449 | SUGGESTION 450 | SUGGESTION 451 | SUGGESTION 452 | SUGGESTION 453 | SUGGESTION 454 | DO_NOT_SHOW 455 | DO_NOT_SHOW 456 | SUGGESTION 457 | SUGGESTION 458 | SUGGESTION 459 | HINT 460 | SUGGESTION 461 | SUGGESTION 462 | SUGGESTION 463 | HINT 464 | SUGGESTION 465 | HINT 466 | HINT 467 | SUGGESTION 468 | SUGGESTION 469 | SUGGESTION 470 | SUGGESTION 471 | SUGGESTION 472 | SUGGESTION 473 | SUGGESTION 474 | SUGGESTION 475 | SUGGESTION 476 | SUGGESTION 477 | SUGGESTION 478 | SUGGESTION 479 | SUGGESTION 480 | WARNING 481 | WARNING 482 | SUGGESTION 483 | SUGGESTION 484 | SUGGESTION 485 | SUGGESTION 486 | DO_NOT_SHOW 487 | SUGGESTION 488 | SUGGESTION 489 | SUGGESTION 490 | SUGGESTION 491 | HINT 492 | SUGGESTION 493 | SUGGESTION 494 | SUGGESTION 495 | SUGGESTION 496 | SUGGESTION 497 | SUGGESTION 498 | WARNING 499 | DO_NOT_SHOW 500 | DO_NOT_SHOW 501 | SUGGESTION 502 | SUGGESTION 503 | WARNING 504 | WARNING 505 | WARNING 506 | HINT 507 | WARNING 508 | WARNING 509 | WARNING 510 | WARNING 511 | WARNING 512 | WARNING 513 | WARNING 514 | WARNING 515 | WARNING 516 | WARNING 517 | WARNING 518 | WARNING 519 | WARNING 520 | WARNING 521 | WARNING 522 | WARNING 523 | SUGGESTION 524 | SUGGESTION 525 | WARNING 526 | SUGGESTION 527 | SUGGESTION 528 | SUGGESTION 529 | SUGGESTION 530 | WARNING 531 | WARNING 532 | SUGGESTION 533 | SUGGESTION 534 | WARNING 535 | WARNING 536 | WARNING 537 | WARNING 538 | WARNING 539 | WARNING 540 | WARNING 541 | WARNING 542 | WARNING 543 | WARNING 544 | WARNING 545 | WARNING 546 | WARNING 547 | WARNING 548 | WARNING 549 | WARNING 550 | WARNING 551 | WARNING 552 | WARNING 553 | WARNING 554 | WARNING 555 | WARNING 556 | WARNING 557 | WARNING 558 | WARNING 559 | WARNING 560 | WARNING 561 | WARNING 562 | WARNING 563 | WARNING 564 | WARNING 565 | WARNING 566 | WARNING 567 | WARNING 568 | WARNING 569 | WARNING 570 | WARNING 571 | WARNING 572 | WARNING 573 | WARNING 574 | WARNING 575 | WARNING 576 | WARNING 577 | WARNING 578 | WARNING 579 | WARNING 580 | WARNING 581 | WARNING 582 | WARNING 583 | WARNING 584 | WARNING 585 | WARNING 586 | WARNING 587 | WARNING 588 | SUGGESTION 589 | SUGGESTION 590 | WARNING 591 | WARNING 592 | WARNING 593 | WARNING 594 | WARNING 595 | WARNING 596 | WARNING 597 | ERROR 598 | DO_NOT_SHOW 599 | DO_NOT_SHOW 600 | DO_NOT_SHOW 601 | DO_NOT_SHOW 602 | DO_NOT_SHOW 603 | DO_NOT_SHOW 604 | DO_NOT_SHOW 605 | DO_NOT_SHOW 606 | DO_NOT_SHOW 607 | DO_NOT_SHOW 608 | DO_NOT_SHOW 609 | DO_NOT_SHOW 610 | DO_NOT_SHOW 611 | DO_NOT_SHOW 612 | DO_NOT_SHOW 613 | DO_NOT_SHOW 614 | DO_NOT_SHOW 615 | DO_NOT_SHOW 616 | DO_NOT_SHOW 617 | DO_NOT_SHOW 618 | DO_NOT_SHOW 619 | DO_NOT_SHOW 620 | DO_NOT_SHOW 621 | DO_NOT_SHOW 622 | DO_NOT_SHOW 623 | DO_NOT_SHOW 624 | DO_NOT_SHOW 625 | DO_NOT_SHOW 626 | DO_NOT_SHOW 627 | DO_NOT_SHOW 628 | DO_NOT_SHOW 629 | DO_NOT_SHOW 630 | DO_NOT_SHOW 631 | DO_NOT_SHOW 632 | DO_NOT_SHOW 633 | DO_NOT_SHOW 634 | DO_NOT_SHOW 635 | DO_NOT_SHOW 636 | DO_NOT_SHOW 637 | ERROR 638 | ERROR 639 | ERROR 640 | ERROR 641 | ERROR 642 | ERROR 643 | ERROR 644 | ERROR 645 | ERROR 646 | ERROR 647 | ERROR 648 | ERROR 649 | ERROR 650 | ERROR 651 | ERROR 652 | ERROR 653 | ERROR 654 | ERROR 655 | ERROR 656 | ERROR 657 | ERROR 658 | ERROR 659 | ERROR 660 | ERROR 661 | ERROR 662 | ERROR 663 | ERROR 664 | ERROR 665 | ERROR 666 | ERROR 667 | ERROR 668 | ERROR 669 | ERROR 670 | ERROR 671 | ERROR 672 | ERROR 673 | ERROR 674 | ERROR 675 | ERROR 676 | ERROR 677 | ERROR 678 | ERROR 679 | ERROR 680 | ERROR 681 | ERROR 682 | ERROR 683 | ERROR 684 | ERROR 685 | ERROR 686 | ERROR 687 | ERROR 688 | ERROR 689 | ERROR 690 | ERROR 691 | ERROR 692 | ERROR 693 | ERROR 694 | ERROR 695 | ERROR 696 | ERROR 697 | ERROR 698 | ERROR 699 | ERROR 700 | ERROR 701 | ERROR 702 | ERROR 703 | ERROR 704 | ERROR 705 | ERROR 706 | ERROR 707 | ERROR 708 | ERROR 709 | ERROR 710 | ERROR 711 | ERROR 712 | ERROR 713 | ERROR 714 | ERROR 715 | ERROR 716 | ERROR 717 | ERROR 718 | ERROR 719 | ERROR 720 | ERROR 721 | ERROR 722 | ERROR 723 | ERROR 724 | ERROR 725 | ERROR 726 | ERROR 727 | ERROR 728 | ERROR 729 | ERROR 730 | ERROR 731 | ERROR 732 | ERROR 733 | ERROR 734 | ERROR 735 | ERROR 736 | ERROR 737 | ERROR 738 | ERROR 739 | ERROR 740 | ERROR 741 | ERROR 742 | ERROR 743 | ERROR 744 | ERROR 745 | ERROR 746 | ERROR 747 | ERROR 748 | ERROR 749 | ERROR 750 | ERROR 751 | ERROR 752 | WARNING 753 | SUGGESTION 754 | WARNING 755 | WARNING 756 | 757 | 758 | 759 | 760 | True 761 | True 762 | True 763 | True 764 | 765 | DISABLED 766 | IMPLICIT_WHEN_INITIALIZER_HAS_TYPE 767 | ALWAYS_EXPLICIT 768 | 769 | True 770 | False 771 | False 772 | False 773 | 774 | True 775 | False 776 | 777 | 778 | 779 | False 780 | False 781 | True 782 | False 783 | 784 | True 785 | True 786 | 787 | True 788 | 789 | False 790 | False 791 | False 792 | False 793 | False 794 | False 795 | False 796 | False 797 | False 798 | False 799 | ReplaceAll 800 | True 801 | False 802 | False 803 | True 804 | 805 | 806 | True 807 | True 808 | True 809 | True 810 | True 811 | True 812 | True 813 | True 814 | 815 | 816 | True 817 | 818 | 819 | Alphabetical 820 | FullyQualify 821 | True 822 | True 823 | 824 | 825 | True 826 | True 827 | True 828 | True 829 | True 830 | True 831 | True 832 | True 833 | True 834 | 835 | 836 | True 837 | True 838 | True 839 | True 840 | True 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | --------------------------------------------------------------------------------