ISearchProvider-Schnittstelle
Stellt eine Abstraktion für einen Suchanbieter zur Implementierung eines benutzerdefinierten Suchanbieters bereit, der verwendet werden kann, um den Standardsuchanbieter ausschließlich für den Such- und Verarbeitungszeitgeberauftrag zu ersetzen.
Namespace: Microsoft.Office.RecordsManagement.SearchAndProcess
Assembly: Microsoft.Office.Policy (in Microsoft.Office.Policy.dll)
Syntax
'Declaration
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Interface ISearchProvider
'Usage
Dim instance As ISearchProvider
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public interface ISearchProvider
Hinweise
Benötigen Sie für den Zeitgeberauftrag suchen und verarbeiten einen benutzerdefinierten Suchanbieter hinzufügen möchten, implementieren Sie diese Schnittstelle und registrieren Sie die SearchProvider. Registrieren von den Suchanbieter mithilfe der Methode RegisterSearchEngine ersetzt den Standardsuchanbieter mit Ihren benutzerdefinierten Suchanbieter. Dies ersetzt nicht allgemein den Suchanbieter für das gesamte System, sondern nur für den Zeitgeberauftrag suchen und verarbeiten.
Beispiele
public class CustomSearchEngine : ISearchProvider {to implement // Return a search iterator object that provides search results within the passedto implement // in SPWeb.to implement public ISearchEnumerator PerformSearch(ISearchParameters param, SPWeb web)to implement {to implementto implement return new CustomSearchIterator(web);to implement }to implementto implement /// <summary>to implement /// place holder implementation for GetSearchPageUrlto implement /// </summary>to implement /// <param name="web">Search web name</param>to implement /// <returns>string</returns>to implement public string GetSearchPageUrl(SPWeb web)to implement {to implementto implement return "/_layouts/customsearch.aspx";to implement }}to implementpublic class CustomSearchIterator : ISearchEnumerator{to implement private SPList m_currentList = null;to implement private IEnumerator m_itemsIterator = null;to implementto implement /// <summary>to implement /// Constructor of the search iterator. Here we find a list in the SPWeb withto implement /// the supplied title. All items in the list will be returned as search results.to implement /// </summary>to implement public CustomSearchIterator(SPWeb web)to implement {to implementto implement m_currentList = web.Lists["customlistforsearch"];to implementto implement if (m_currentList != null)to implementto implement {to implementm_itemsIterator = m_currentList.Items.GetEnumerator();to implementto implement }to implement }to implementto implement /// <summary>to implement /// Move to the next item in the search results.to implement /// Essentially this method tells whether it's the end of search results.to implement /// </summary>to implement /// <returns>Return false if it's the end of search results. Otherwise return true.</returns>to implement public bool MoveNext()to implement {to implementto implement return m_itemsIterator.MoveNext();to implement }to implementto implement // Never called. No need to implement.to implement public void Reset()to implement {to implement }to implementto implement /// <summary>to implement /// Return the current item in the search results.to implement /// Here we just return the full URL of current item from a SPListItemCollection enumerator.to implement /// </summary>to implement public object Currentto implement {to implementto implement getto implementto implement {to implementSPListItem currentItem = (SPListItem) m_itemsIterator.Current;to implementstring itemUrl = SPUrlUtility.CombineUrl(currentItem.Web.Url, currentItem.Url);to implementreturn (object)itemUrl;to implementto implement }to implement }to implementto implement /// <summary>to implement /// Whether the current item from search results is null.to implement /// </summary>to implement public bool IsNullto implement {to implementto implement getto implementto implement {to implementreturn (Current == null);to implementto implement }to implement }}
Siehe auch
Referenz
Microsoft.Office.RecordsManagement.SearchAndProcess-Namespace