Beispiel #1
0
        protected override void ProcessRecord()
        {
            Everything.Reset();
            Everything.SetMatchCase(CaseSensitive);
            Everything.SetMatchWholeWord(MatchWholeWord);
            Everything.SetRegEx(!String.IsNullOrEmpty(RegularExpression));

            ulong skip = PagingParameters.Skip;

            if (skip > int.MaxValue)
            {
                ThrowTerminatingError(new ErrorRecord(new ParameterBindingException("Cannot skip that many results"), "SkipToLarge", ErrorCategory.InvalidArgument, skip));
            }

            ulong first = PagingParameters.First;

            if (first == ulong.MaxValue)
            {
                first = int.MaxValue;
            }
            if (first > int.MaxValue)
            {
                ThrowTerminatingError(new ErrorRecord(new ParameterBindingException("Cannot take that many results"), "FirstToLarge", ErrorCategory.InvalidArgument, first));
            }
            if (first < Int32.MaxValue)
            {
                Everything.SetMax((int)first);
            }
            if (skip > 0)
            {
                Everything.SetOffset((int)skip);
            }


            var searchPattern = GetSearchString();

            WriteDebug("Search-Everything search pattern:" + searchPattern);
            Everything.SetSearch(searchPattern);

            try {
                Everything.Query(true);
                Everything.SortResultsByPath();
                int resCount = Everything.GetTotalNumberOfResults();
                if (PagingParameters.IncludeTotalCount)
                {
                    var total = PagingParameters.NewTotalCount((ulong)resCount, 1.0);
                    WriteObject(total);
                }
                var res = Everything.GetAllResults(Math.Min(resCount, (int)first));
                WriteObject(res, enumerateCollection: !AsArray);
            }
            catch (Exception e)
            {
                ThrowTerminatingError(new ErrorRecord(e, e.Message, ErrorCategory.NotSpecified, searchPattern));
            }
        }
Beispiel #2
0
 void IDisposable.Dispose()
 {
     Everything.Cleanup();
 }