DocumentSetTemplate-Klasse

Die Vorlage, die Grundlage für DocumentSet -Objekte darstellt.

Vererbungshierarchie

System.Object
  Microsoft.Office.DocumentManagement.DocumentSets.DocumentSetTemplate

Namespace:  Microsoft.Office.DocumentManagement.DocumentSets
Assembly:  Microsoft.Office.DocumentManagement (in Microsoft.Office.DocumentManagement.dll)

Syntax

'Declaration
Public Class DocumentSetTemplate
'Usage
Dim instance As DocumentSetTemplate
public class DocumentSetTemplate

Hinweise

Gibt eine Vorlage für jeden Inhaltstyp des Dokuments festlegen und eine Vorlage für jeden Inhaltstyp ein, die von ihr erbt. Vorlagen beschreiben die Eigenschaften der Inhaltstyp des Dokuments festlegen. Diese Eigenschaften umfassen die Inhaltstypen zulässig in der Dokumentenmappe, die Standarddokumente, die freigegebene Felder, die Felder, die in der Willkommensseite und der Ansicht für die Seite Willkommen angezeigt werden.

Beispiele

using System;
using Microsoft.SharePoint;
using Microsoft.Office.DocumentManagement.DocumentSets;

namespace SyncAllDocsetTemplates
{
class Program
{
static void Main(string[] args)
{
//Sets a field as shared and adds an allowed content type
//to all document set content types, the field that is now
//shared will be displayed on the welcome page
//and all of the default documents will be made to have the
//newly allowed content type
using (SPSite site = new SPSite("https://localhost")) //get the site
{
using (SPWeb web = site.RootWeb)  //get the web
{
SPField field = web.Fields["ExistingField"];//get the new field
SPContentType contentType = web.ContentTypes["ExistingCT"];//get the new content type
foreach (SPContentType ct in web.ContentTypes)//iterate through all content types
{
if (DocumentSetTemplate.Id.IsParentOf(ct.Id) || ct.Id == DocumentSetTemplate.Id)//only take action if it's the base document set content type or one of its childs
{
//Get the document set template
DocumentSetTemplate docsetTemplate = DocumentSetTemplate.GetDocumentSetTemplate(ct);
//Add the new content type, make the field shared, and add it to the welcomepage
docsetTemplate.AllowedContentTypes.Add(contentType.Id);
docsetTemplate.SharedFields.Add(field);
docsetTemplate.WelcomePageFields.Add(field);
//Change the content type of all default documents to the new content type
foreach (DefaultDocument defDoc in docsetTemplate.DefaultDocuments)
{
docsetTemplate.DefaultDocuments.ChangeContentTypeForDocument(defDoc.Name, contentType.Id);
}
//Finally, save the changes
docsetTemplate.Update(false);
}
}
}
}
}
}
}

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Die Threadsicherheit von Instanzmembern ist nicht gewährleistet.

Siehe auch

Referenz

DocumentSetTemplate-Member

Microsoft.Office.DocumentManagement.DocumentSets-Namespace

DocumentSet