次の方法で共有


ContentSourceCollection.Create メソッド (Microsoft.Office.Server.Search.Administration)

コレクションに新しいコンテンツ ソースを作成します。

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

構文

'宣言
Public Function Create ( _
    type As Type, _
    name As String _
) As ContentSource
'使用
Dim instance As ContentSourceCollection
Dim type As Type
Dim name As String
Dim returnValue As ContentSource

returnValue = instance.Create(type, name)
public ContentSource Create (
    Type type,
    string name
)

パラメータ

  • type
    コンテンツ ソースのオブジェクトの種類。
  • name
    コンテンツ ソース名を含む文字列。

戻り値

ContentSource オブジェクト。

備考

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

次のコード例は、新しいカスタム コンテンツ ソースを作成します。ContentSourceCollection クラスの Create メソッドのサンプル コードを実行して完成させるには、「[方法] コンテンツ ソースを追加する」を参照してください。

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 AddContentSourceSample
{
    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;
            //Replace <csName> with the content source name.
            CustomContentSource customCS = (CustomContentSource)sspContentSources.Create(typeof(CustomContentSource), "<csName>");

        }
    }
}

関連項目

参照

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