SearchContext.GetContext Method (SPSite)
NOTE: This API is now obsolete.
Gets the search context instance for the specified SPSite object.
Namespace: Microsoft.Office.Server.Search.Administration
Assembly: Microsoft.Office.Server.Search (in Microsoft.Office.Server.Search.dll)
Syntax
'Declaration
<ObsoleteAttribute("This class is obsolete now. Please use SearchServiceApplication and SearchServiceApplicationProxy instead.")> _
Public Shared Function GetContext ( _
site As SPSite _
) As SearchContext
'Usage
Dim site As SPSite
Dim returnValue As SearchContext
returnValue = SearchContext.GetContext(site)
[ObsoleteAttribute("This class is obsolete now. Please use SearchServiceApplication and SearchServiceApplicationProxy instead.")]
public static SearchContext GetContext(
SPSite site
)
Parameters
- site
Type: Microsoft.SharePoint.SPSite
Return Value
Type: Microsoft.Office.Server.Search.Administration.SearchContext
A SearchContext object.
Remarks
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 SharePoint Enterprise Search Administration object model, see Getting Started with the Search Administration Object Model and How to: Return the Search Context for the Search Service Provider.
Examples
[C#]
SearchContext context;
using (SPSite site = new SPSite("http://yourSiteName"))
{
context = SearchContext.GetContext(site);
}