Ejemplo n.º 1
0
        /// <summary>
        /// Execute a search request that will fetch search results asynchronously.
        /// </summary>
        /// <param name="context">Search context used to track asynchronous request.</param>
        /// <param name="options">Options defining how the query will be performed</param>
        /// <returns>Asynchronous list of search items.</returns>
        public static ISearchList Request(SearchContext context, SearchFlags options = SearchFlags.None)
        {
            ISearchList results = null;

            if (!InternalEditorUtility.CurrentThreadIsMainThread())
            {
                results = new ConcurrentSearchList(context);

                Dispatcher.Enqueue(() =>
                {
                    results.AddItems(GetItems(context, options));
                    (results as ConcurrentSearchList)?.GetItemsDone();
                });

                return(results);
            }

            if (options.HasAny(SearchFlags.Sorted))
            {
                results = new SortedSearchList(context);
            }
            else
            {
                results = new AsyncSearchList(context);
            }

            results.AddItems(GetItems(context, options));
            return(results);
        }
Ejemplo n.º 2
0
 public SearchSelection(IEnumerable <SearchItem> items)
 {
     m_Items     = new List <SearchItem>(items);
     m_Selection = new List <int>();
     for (int i = 0; i < m_Items.Count; ++i)
     {
         m_Selection.Add(i);
     }
     m_List = null;
 }
Ejemplo n.º 3
0
        private void AddSearchItemsAsConverterAssetEntries(ISearchList searchItems, InitializeConverterContext context)
        {
            foreach (var searchItem in searchItems)
            {
                if (searchItem == null || !GlobalObjectId.TryParse(searchItem.id, out var globalId))
                {
                    continue;
                }

                var description = searchItem.provider.fetchDescription(searchItem, searchItem.context);

                var item = new ConverterItemDescriptor()
                {
                    name = description.Split('/').Last().Split('.').First(),
                    info = $"{ReturnType(globalId)}",
                };

                guids.Add(globalId.ToString());
                context.AddAssetToConvert(item);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Execute a search request that will fetch search results asynchronously.
        /// </summary>
        /// <param name="context">Search context used to track asynchronous request.</param>
        /// <param name="options">Options defining how the query will be performed</param>
        /// <returns>Asynchronous list of search items.</returns>
        public static ISearchList Request(SearchContext context, SearchFlags options = SearchFlags.None)
        {
            if (options.HasFlag(SearchFlags.Synchronous))
            {
                throw new NotSupportedException($"Use {nameof(SearchService)}.{nameof(GetItems)}(context, " +
                                                $"{nameof(SearchFlags)}.{nameof(SearchFlags.Synchronous)}) to fetch items synchronously.");
            }

            ISearchList results = null;

            if (options.HasFlag(SearchFlags.Sorted))
            {
                results = new SortedSearchList(context);
            }
            else
            {
                results = new AsyncSearchList(context);
            }

            results.AddItems(GetItems(context, options));
            return(results);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a new SearchSelection
 /// </summary>
 /// <param name="selection">Current list of selected SearchItem indices.</param>
 /// <param name="filteredItems">List of SearchItem displayed in QuickSearch.</param>
 public SearchSelection(IList <int> selection, ISearchList filteredItems)
 {
     m_Selection = selection;
     m_List      = filteredItems;
 }