ManagedPropertyCollection 类 (Microsoft.Office.Server.Search.Administration)

Represents a collection of ManagedProperty objects.

命名空间: Microsoft.Office.Server.Search.Administration
程序集: Microsoft.Office.Server.Search (在 microsoft.office.server.search.dll 中)

语法

声明
<DefaultMemberAttribute("Item")> _
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel:=True)> _
Public NotInheritable Class ManagedPropertyCollection
    Implements IEnumerable
用法
Dim instance As ManagedPropertyCollection
[DefaultMemberAttribute("Item")] 
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel=true)] 
public sealed class ManagedPropertyCollection : IEnumerable

备注

Use the AllManagedProperties property of the Schema class to get the collection of managed properties in the Shared Service Provider's search schema.

To add a new managed property to the collection, use the Create method.

Use an indexer to return a single managed property from the ManagedPropertyCollection object. For example, assuming the collection is assigned to a variable named mProperties, use mProperties[index] in Microsoft Visual C# or mProperties(index) in Microsoft Visual Basic, where index is a string containing the name of the managed property.

示例

The following code example writes out the full list of managed properties to the console window. For a complete, step-by-step walkthrough of this sample code, see 如何:检索共享服务提供程序的托管属性.

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;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.SharePoint;

namespace ManagedPropertiesSample
{
    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)));
                ManagedPropertyCollection properties = sspSchema.AllManagedProperties;
                foreach (ManagedProperty property in properties)
                {
                    Console.WriteLine(property.Name);
                }
            }
            catch(Exception ex)
            {
                 Console.WriteLine(ex.ToString());
            }
        }
    }
}

继承层次结构

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

线程安全性

此类型的任何公共静态( Visual Basic 中共享)成员是线程安全的。不保证任何实例成员都是线程安全的。

另请参阅

参考

ManagedPropertyCollection 成员
Microsoft.Office.Server.Search.Administration 命名空间