public async Task<IList<object>> SuggestAsync(object data, string input, IHierarchyHelper helper)
 {
     List<object> retVal = new List<object>();
     foreach (var ss in _suggestSources)
         retVal.AddRange(await ss.SuggestAsync(data, input, helper));
     return retVal;
 }
 public Task <IList <object> > SuggestAsync(object data, string input, IHierarchyHelper helper)
 {
     return(Task.FromResult <IList <object> >(new List <object>()
     {
         new { Header = input + "-add xyz", Value = input + "xyz" },
         new { Header = input + "-add abc", Value = input + "abc" }
     }));
 }
 public ProjectItemsSynchronizer(Project sourceProject, Project targetProject, ILogger logger, IVsSolution solution, IHierarchyHelper hierarchyHelper, IProjectItemsFilter projectItemsFilter)
 {
     this.logger = logger;
     this.solution = solution;
     this.hierarchyHelper = hierarchyHelper;
     SourceProject = sourceProject;
     TargetProject = targetProject;
     this.projectItemsFilter = projectItemsFilter;
 }
 public ProjectItemsSynchronizer(Project sourceProject, Project targetProject, ILogger logger, IVsSolution solution,
                                 IHierarchyHelper hierarchyHelper, IProjectItemsFilter projectItemsFilter)
 {
     _logger             = logger;
     _solution           = solution;
     _hierarchyHelper    = hierarchyHelper;
     SourceProject       = sourceProject;
     TargetProject       = targetProject;
     _projectItemsFilter = projectItemsFilter;
 }
        /// <summary>
        /// Method returns a task that returns a list of suggestion objects
        /// that are associated to the <paramref name="input"/> string
        /// and given <paramref name="data"/> object.
        ///
        /// The list of suggestion is empty if helper object is null.
        ///
        /// This method is usually directly invoked by the SuggestBox to query data
        /// sources for suggestions as the user types a string character by character.
        /// </summary>
        /// <param name="location">Represents the root of the hierarchy that is browsed here.</param>
        /// <param name="input">Is the input string typed by the user.</param>
        /// <returns></returns>
        public Task <SuggestQueryResultModel> SuggestAsync(LocationIndicator location,
                                                           string input)
        {
            SuggestQueryResultModel retVal = new SuggestQueryResultModel();

            if (location == null)
            {
                return(Task.FromResult <SuggestQueryResultModel>(retVal));
            }

            IHierarchyHelper hhelper = location.HierarchyHelper;

            if (hhelper == null)
            {
                return(Task.FromResult <SuggestQueryResultModel>(retVal));
            }

            // Get the path from input string: 'c:\Windows' -> path: 'c:\'
            string valuePath = hhelper.ExtractPath(input);

            // Get the name from input string: 'c:\Windows' -> path: 'Windows'
            string valueName = hhelper.ExtractName(input);

            // Ensure that name ends with seperator if input ended with a seperator
            if (String.IsNullOrEmpty(valueName) && input.EndsWith(hhelper.Separator + ""))
            {
                valueName += hhelper.Separator;
            }

            // Ensure valid path if input ends with seperator and path was currently empty
            if (valuePath == "" && input.EndsWith("" + hhelper.Separator))
            {
                valuePath = valueName;
            }

            var found = hhelper.GetItem(location.RootItem, valuePath);

            if (found != null)
            {
                foreach (var item in hhelper.List(found))
                {
                    string valuePathName = hhelper.GetPath(item) as string;

                    if (valuePathName.StartsWith(input, hhelper.StringComparisonOption) &&
                        !valuePathName.Equals(input, hhelper.StringComparisonOption))
                    {
                        retVal.ResultList.Add(item);
                    }
                }
            }

            return(Task.FromResult <SuggestQueryResultModel>(retVal));
        }
        public async Task <IList <object> > SuggestAsync(object data, string input, IHierarchyHelper helper)
        {
            string dir       = input.EndsWith(_profile.Path.Separator + "") ? input : _profile.Path.GetDirectoryName(input);
            string searchStr = _profile.Path.GetFileName(input);

            if (String.IsNullOrEmpty(searchStr) && input.EndsWith(_profile.Path.Separator + ""))
            {
                searchStr += _profile.Path.Separator;
            }

            if (dir == "" && input.EndsWith(_profile.Path.Separator + ""))
            {
                dir = searchStr;
            }
            var found = await _profile.ParseAsync(dir);

            List <object> retVal = new List <object>();

            if (found != null)
            {
                if (_cts != null)
                {
                    _cts.Cancel();
                }
                var cts = _cts = new CancellationTokenSource();
                foreach (var item in await _profile.ListAsync(found, _cts.Token, em => em.IsDirectory))
                {
                    if (cts.IsCancellationRequested)
                    {
                        break;
                    }
                    if (item.FullPath.StartsWith(input, StringComparison.CurrentCultureIgnoreCase) &&
                        !item.FullPath.Equals(input, StringComparison.CurrentCultureIgnoreCase))
                    {
                        retVal.Add(item);
                    }
                }
                if (cts.IsCancellationRequested)
                {
                    return(new List <object>());
                }
            }

            return(retVal);
        }
Example #7
0
        public async Task <IList <object> > SuggestAsync(object data, string input, IHierarchyHelper helper)
        {
            if (helper == null)
            {
                return(ImmutableList <object> .Empty);
            }

            var valuePath = helper.ExtractPath(input);
            var valueName = helper.ExtractName(input);

            if (string.IsNullOrEmpty(valueName) && input.EndsWith(helper.Separator + ""))
            {
                valueName += helper.Separator;
            }

            if (valuePath == "" && input.EndsWith("" + helper.Separator))
            {
                valuePath = valueName;
            }
            var found = await helper.GetItemAsync(data, valuePath);

            if (found == null)
            {
                return(ImmutableList <object> .Empty);
            }

            var result = new List <object>();
            var enuma  = await helper.ListAsync(found);

            foreach (var item in enuma)
            {
                string valuePathName = helper.GetPath(item);
                if (valuePathName.StartsWith(input, helper.StringComparisonOption) &&
                    !valuePathName.Equals(input, helper.StringComparisonOption))
                {
                    result.Add(item);
                }
            }

            return(result);
        }
        public Task <IList <object> > SuggestAsync(object data, string input, IHierarchyHelper helper)
        {
            if (helper == null)
            {
                return(Task.FromResult <IList <object> >(new List <Object>()));
            }

            string valuePath = helper.ExtractPath(input);
            string valueName = helper.ExtractName(input);

            if (String.IsNullOrEmpty(valueName) && input.EndsWith(helper.Separator + ""))
            {
                valueName += helper.Separator;
            }

            if (valuePath == "" && input.EndsWith("" + helper.Separator))
            {
                valuePath = valueName;
            }
            var           found  = helper.GetItem(data, valuePath);
            List <object> retVal = new List <object>();

            if (found != null)
            {
                foreach (var item in helper.List(found))
                {
                    string valuePathName = helper.GetPath(item) as string;
                    if (valuePathName.StartsWith(input, helper.StringComparisonOption) &&
                        !valuePathName.Equals(input, helper.StringComparisonOption))
                    {
                        retVal.Add(item);
                    }
                }
            }



            return(Task.FromResult <IList <object> >(retVal));
        }
Example #9
0
 /// <summary>
 /// Class constructor
 /// </summary>
 public LocationIndicator(object rootItemParam, IHierarchyHelper hierarchyHelperParam)
 {
     this.RootItem        = rootItemParam;
     this.HierarchyHelper = hierarchyHelperParam;
 }
 public PathExistsValidationRule(IHierarchyHelper hierarchyHelper, object root)
 {
     _hierarchyHelper = hierarchyHelper;
     _root            = root;
 }
Example #11
0
 public Task <IList <object> > SuggestAsync(object data, string input, IHierarchyHelper helper)
 {
     return(Task.Run <IList <object> >(() => new List <object>()));
 }