Partager via


SearchContext.GetContext, méthode (SPSite) (Microsoft.Office.Server.Search.Administration)

Gets the search context instance for the specified SPSite object.

Espace de noms : Microsoft.Office.Server.Search.Administration
Assembly : Microsoft.Office.Server.Search (dans microsoft.office.server.search.dll)

Syntaxe

'Déclaration
Public Shared Function GetContext ( _
    site As SPSite _
) As SearchContext
'Utilisation
Dim site As SPSite
Dim returnValue As SearchContext

returnValue = SearchContext.GetContext(site)
public static SearchContext GetContext (
    SPSite site
)

Paramètres

  • site

Valeur de retour

A SearchContext object.

Remarques

If you specify an SPSite object in the GetContext method to retrieve the search context, we recommend that your code instantiates the SPSite object within a using statement to ensure the object is released once it's no longer needed. See code in the Example section.

For more information about the SearchContext class and the Recherche de contenu d'entreprise Administration object model, see Mise en route avec le modèle objet Administration de recherche de contenu d'entreprise and Procédure : renvoyer le contexte de recherche pour le fournisseur du service de recherche.

Exemple

[C#]

SearchContext context;
using (SPSite site = new SPSite("http://yourSiteName"))
{
     context = SearchContext.GetContext(site);

}

Voir aussi

Référence

SearchContext, classe
Membres SearchContext
Microsoft.Office.Server.Search.Administration, espace de noms