次の方法で共有


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

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

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

構文

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

備考

共有サービス プロバイダの検索スキーマにある管理プロパティのコレクションを取得するには、Schema クラスの AllCategories プロパティを使用します。

CategoryCollection オブジェクトから 1 つのカテゴリを返すには、インデクサを使用します。たとえば、コレクションが categories という名前の変数に割り当てられている場合、Microsoft Visual C# では categories[index]、または Microsoft Visual Basic では categories(index) を使用します。ここで index は、カテゴリの名前を含む文字列またはカテゴリのプロパティ セットを識別する GUID です。

検索スキーマに新しいカテゴリを作成するには、CategoryCollection クラスの Create メソッドを使用します。

検索スキーマのカテゴリを削除するには、Category クラスの Delete メソッドを使用します。

以下のコード例は、コンソール ウィンドウにカテゴリの完全なリストを出力します。

Prerequisites

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

Project References

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

  • Microsoft.SharePoint

  • Microsoft.Office.Server

  • Microsoft.Office.Server.Search

using System;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.SharePoint;
namespace CategoriesSample
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                //Replace <SiteName> with the name of a site using the Shared Service Provider.
                string strURL = "http://<SiteName>";
                Schema sspSchema = new Schema(SearchContext.GetContext(new SPSite(strURL)));
                CategoryCollection categories = sspSchema.AllCategories;
                foreach (Category category in categories)
                {
                    Console.WriteLine(category.Name);
                }
            }
            catch(Exception ex)
            {
                 Console.WriteLine(ex.ToString());
            }
        }
    }
}

継承階層

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

スレッドの安全性

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

関連項目

参照

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