ContentSourceCollection クラス (Microsoft.Office.Server.Search.Administration)

ContentSource オブジェクトのコレクションを表します。

名前空間: Microsoft.Office.Server.Search.Administration
アセンブリ: Microsoft.Office.Server.Search (microsoft.office.server.search.dll 内)

構文

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

備考

コンテンツ ソースおよび エンタープライズ検索 の新しい管理オブジェクト モデルの詳細については、「コンテンツ ソースの概要」および「Getting Started with the Search Administration Object Model」を参照してください。

共有サービス プロバイダのコンテンツ ソースのコレクションを取得するには、Content クラスの ContentSources プロパティを使用します。

コレクションに新しいコンテンツ ソースを追加するには、ContentSourceCollection クラスの Create メソッドを使用します。

コンテンツ ソースを削除するには、ContentSource クラスの Delete メソッドを使用します。

ContentSourceCollection オブジェクトから 1 つのコンテンツ ソースを返すには、インデクサを使用します。たとえば、コレクションが sspContentSources という名前の変数に割り当てられている場合、Microsoft Visual C# では sspContentSources[index]、または Microsoft Visual Basic では sspContentSources(index) を使用します。ここで、index はコンテンツ ソースの名前を含む文字列またはコンテンツ ソースの ID を含む整数です。

以下のコード例は、共有サービス プロバイダのコンテンツ ソースの完全なリストをコンソール ウィンドウに出力します。

Prerequisites

共有サービス プロバイダが既に作成されていることを確認します。

Project References

このサンプルを実行する前に、コンソール アプリケーション コード プロジェクトに以下のプロジェクト参照を追加します。

  • 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);
            }
        }
    }
}

継承階層

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

スレッドの安全性

この型のパブリックで静的な (Visual Basic では Shared) すべてのメンバは、スレッド セーフです。インスタンス メンバは、スレッド セーフであるとは保証されません。

関連項目

参照

ContentSourceCollection メンバ
Microsoft.Office.Server.Search.Administration 名前空間