Share via


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

Represents the top-level object for administration of the content sources for a Shared Services Provider's (SSP) search service.

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

语法

声明
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
Public NotInheritable Class Content
用法
Dim instance As Content
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
public sealed class Content

备注

Use the constructor of the Content class to create a Content object that allows you to access and administer the content sources for an SSP.

For more information about content sources and the new 企业级搜索 Administration object model, see 内容源概述, 管理内容, and Getting Started with the Search Administration Object Model.

示例

The following code example writes out the full list of content sources for an SSP to a console window. For a complete, step-by-step walkthrough of this sample code, see 如何:检索共享服务提供程序的内容源.

Prerequisites

Ensure an SSP 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;
using System.Text;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.SharePoint;

namespace ContentSourcesSample
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            Replace <SiteName> with the name of
            a site using the Shared Services 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.Content

线程安全性

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

另请参阅

参考

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

其他资源

企业级搜索管理对象模型入门
内容源概述
管理内容
如何:检索共享服务提供程序的内容源
如何:添加内容源
如何:删除内容源
如何:以编程方式管理对内容源的爬网
如何:以编程方式配置内容源的爬网计划