public IList <IntellisenseProviderResult> GetIntellisenseResults(IntellisenseProviderContext context)
        {
            if (context == null)
            {
                return(new List <IntellisenseProviderResult>());
            }

            var results = new List <IntellisenseProviderResult>();

            if (context.DesiredResultSet == IntellisenseDesiredResultSet.EntireSet)
            {
                IntellisenseResults.Clear();
                FileSystemQuery.QueryList("");
                FileSystemQuery.QueryCollection.ForEach(s => IntellisenseResults.Add(new IntellisenseProviderResult(this, s, string.Empty, string.Empty, false)));
                results.AddRange(IntellisenseResults);
            }
            else
            {
                if (!InLiteralRegion(context.InputText, context.CaretPosition))
                {
                    IntellisenseResults.Clear();
                    var regions    = context.InputText.Split(' ');
                    var sum        = 0;
                    var searchText = regions.Select(a => new { a, a.Length }).TakeWhile(a =>
                    {
                        sum = sum + context.CaretPosition;
                        return(sum >= context.CaretPosition);
                    }).Last().a;
                    FileSystemQuery.QueryList(searchText);
                    FileSystemQuery.QueryCollection.ForEach(s => IntellisenseResults.Add(new IntellisenseProviderResult(this, s, string.Empty, string.Empty, false)));
                    results.AddRange(IntellisenseResults);
                }
            }
            return(results);
        }
        public void FileSystemQuery_QueryList_NullPath_ExpectLocalDrives()
        {
            //------------Setup for test--------------------------
            var dir = new Mock <IDirectory>();

            dir.Setup(a => a.GetLogicalDrives()).Returns(new[] { "a", "b", "c" });
            var query = new FileSystemQuery(dir.Object, null, new ShareCollectionFactory());

            query.QueryList(null);
            //------------Assert Results-------------------------
            var files = query.QueryCollection;

            Assert.AreEqual(3, files.Count);
            Assert.AreEqual("a", files[0]);
            Assert.AreEqual("b", files[1]);
            Assert.AreEqual("c", files[2]);
        }
        public IList <IntellisenseProviderResult> GetIntellisenseResults(IntellisenseProviderContext context)
        {
            var results = new List <IntellisenseProviderResult>();

            if (context.DesiredResultSet == IntellisenseDesiredResultSet.EntireSet)
            {
                FileSystemQuery.QueryList("");
                FileSystemQuery.QueryCollection.ForEach(s => _intellisenseResults.Add(new IntellisenseProviderResult(this, s, string.Empty, string.Empty, false)));
                results.AddRange(_intellisenseResults);
            }
            else
            {
                if (!InLiteralRegion(context.InputText, context.CaretPosition))
                {
                    _intellisenseResults.Clear();
                    string searchText = context.InputText; //context.InputText.Substring(context.CaretPositionOnPopup, (context.CaretPosition - context.CaretPositionOnPopup));
                    FileSystemQuery.QueryList(searchText);
                    FileSystemQuery.QueryCollection.ForEach(s => _intellisenseResults.Add(new IntellisenseProviderResult(this, s, string.Empty, string.Empty, false)));
                    results.AddRange(_intellisenseResults);
                }
            }
            return(results);
        }