Freigeben über


ContentSourceCollection.Create-Methode (Type, String)

Erstellt eine Inhaltsquelle in der Auflistung.

Namespace:  Microsoft.Office.Server.Search.Administration
Assembly:  Microsoft.Office.Server.Search (in Microsoft.Office.Server.Search.dll)

Syntax

'Declaration
Public Function Create ( _
    type As Type, _
    name As String _
) As ContentSource
'Usage
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
)

Parameter

  • type
    Typ: System.Type

    Der Objekttyp der Inhaltsquelle.

  • name
    Typ: System.String

    Eine Zeichenfolge, die den Namen der Inhaltsquelle.

Rückgabewert

Typ: Microsoft.Office.Server.Search.Administration.ContentSource
Ein ContentSource -Objekt.

Hinweise

Weitere Informationen zu Inhaltsquellen und dem neuen SharePoint-Unternehmenssuche Administration-Objektmodell finden Sie unter Content Sources Overview und Erste Schritte mit Search-Objekt Verwaltungsmodell.

Beispiele

Im folgenden Codebeispiel wird eine benutzerdefinierte Inhaltsquelle erstellt. Eine ausführliche Anleitung im Beispielcode für die Methode Create() der Klasse ContentSourceCollection finden Sie unter How to: Add a Content Source.

Prerequisites

Stellen Sie sicher, dass ein Anbieter für gemeinsame Dienste bereits erstellt ist.

Project References

Fügen Sie vor dem Ausführen dieses Beispiels die folgenden Projektverweise in Ihrem Code Konsolenanwendungsprojekt hinzu:

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

        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.Office.Server.Search.Administration
Imports Microsoft.SharePoint

Namespace AddContentSourceSample
    Module Program
        Sub Main(ByVal args() As String)
            '            
            '            Replace <SiteName > with the name of a site
            '            using the Shared Services Provider.
            '            
            Dim strURL As String = "http://<SiteName>"
            Dim context As SearchContext
            Using site As New SPSite(strURL)
                context = SearchContext.GetContext(site)
            End Using
            Dim sspContent As New Content(context)
            Dim sspContentSources As ContentSourceCollection = sspContent.ContentSources
            ' Replace <csName> with the content source name.
            Dim customCS As CustomContentSource = CType(sspContentSources.Create(GetType(CustomContentSource), "<csName>"), CustomContentSource)

        End Sub
    End Module
End Namespace

Siehe auch

Referenz

ContentSourceCollection Klasse

ContentSourceCollection-Member

Create-Überladung

Microsoft.Office.Server.Search.Administration-Namespace