Share via


ContentSourceCollection, classe (Microsoft.Office.Server.Search.Administration)

Represents a collection of ContentSource objects.

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

Syntaxe

'Déclaration
<DefaultMemberAttribute("Item")> _
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel:=True)> _
Public NotInheritable Class ContentSourceCollection
    Implements IEnumerable
'Utilisation
Dim instance As ContentSourceCollection
[DefaultMemberAttribute("Item")] 
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel=true)] 
public sealed class ContentSourceCollection : IEnumerable

Remarques

For more information about content sources and the new Recherche de contenu d'entreprise Administration object model, see Vue d'ensemble des sources de contenu, and Getting Started with the Search Administration Object Model.

Use the ContentSources property of the Content class to get the collection of content source for a Shared Service Provider.

To add a new content source to the collection, use the Create method of the ContentSourceCollection class.

To delete a content source, use the Delete method of the ContentSource class.

Use an indexer to return a single content source from the ContentSourceCollection object. For example, assuming the collection is assigned to a variable named sspContentSources, use sspContentSources[index] in Microsoft Visual C# or sspContentSources(index) in Microsoft Visual Basic, where index is a string containing the name of the content source or an integer containing the content source ID.

Exemple

The following code example writes out the full list of content sources for a Shared Service Provider to the console window.

Prerequisites

Ensure a Shared Service Provider is already created.

Project References

Add the following Project References in your console application code project before running this sample:

  • Microsoft.SharePoint

  • Microsoft.Office.Server

  • Microsoft.Office.Server.Search

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.SharePoint;

namespace ContentSourceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            Replace <SiteName> with the name of a site
            using the Shared Service Provider.
            */
            string strURL = "http://<SiteName>";
            SearchContext context;
            using(SPSite site = new SPSite(strURL))
            {
            context = SearchContext.GetContext(site);
            }
            Content sspContent = new Content(context);            ContentSourceCollection sspContentSources = sspContent.ContentSources;
            foreach (ContentSource cs in sspContentSources)
            {
                Console.WriteLine("NAME: " + cs.Name + "  ID: " + cs.Id);
            }
        }
    }
}

Hiérarchie d'héritage

System.Object
  Microsoft.Office.Server.Search.Administration.ContentSourceCollection

Sécurité des threads

Les membres statiques publics de ce type (Shared en Visual Basic) sont sécurisés au niveau des threads. Il n'est pas garanti que les membres d'instance soient sécurisés au niveau des threads.

Voir aussi

Référence

Membres ContentSourceCollection
Microsoft.Office.Server.Search.Administration, espace de noms