Compartir a través de


Clase ContentTypePublisher

Publica o anula la publicación de un tipo de contenido en el sitio concentrador.

Jerarquía de la herencia

System.Object
  Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher

Espacio de nombres:  Microsoft.SharePoint.Taxonomy.ContentTypeSync
Ensamblado:  Microsoft.SharePoint.Taxonomy (en Microsoft.SharePoint.Taxonomy.dll)

Sintaxis

'Declaración
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class ContentTypePublisher
'Uso
Dim instance As ContentTypePublisher
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class ContentTypePublisher

Comentarios

Después de una aplicación de servicio de metadatos administrados y su proxy aprovisionados y un sitio se ha designado como el concentrador en la aplicación de servicio, utilice esta clase para publicar o anular la publicación de los tipos de contenido en el sitio concentrador.

Además, utilice esta clase para comprobar si un tipo de contenido en este sitio concentrador se publica y para comprobar si está habilitada la característica de MetadataHub en el concentrador.

Ejemplos

using System;
using System.IO;
using System.Globalization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
using Microsoft.SharePoint.Taxonomy.ContentTypeSync;

namespace Microsoft.SDK.SharePointServer.Samples
{
    public static class ContentTypeSyndicationSamples
    {
        /// <summary>
        /// Demostrates how to use ContentTypePublisher class by creating a new
        /// content type and then publish it and unpublish it.
        /// Before this method is called, a Managed Metadata service application
        /// should be created and a hub has been designated on the service application.
        /// </summary>
        /// <param name="hubSite">
        /// The site that has been designated as the hub
        /// </param>
        public static void UseContentTypePublisher(SPSite hubSite)
        {
            // Get the root web of the site
            SPWeb rootWeb = hubSite.RootWeb;

            // Create a new content type based on Document content type
            SPContentType docCt = rootWeb.ContentTypes["Document"];
            Random random = new Random();
            string newCTName = "Test content type " + random.Next().ToString();
            SPContentType newCt = new SPContentType(docCt,
                rootWeb.ContentTypes,
                newCTName);

            rootWeb.ContentTypes.Add(newCt);

            Console.WriteLine(newCTName + " has been created.");

            // Check if the site is a valid hub site
            if (ContentTypePublisher.IsContentTypeSharingEnabled(hubSite))
            {
                ContentTypePublisher publisher = new ContentTypePublisher(hubSite);

                Console.WriteLine("Publishing the content type. ");
                publisher.Publish(newCt);

                // Check if this content type has been published
                if (publisher.IsPublished(newCt))
                {
                    Console.WriteLine(newCTName + " is a published content type.");
                }

                Console.WriteLine("Unpublishing the content type. ");
                publisher.Unpublish(newCt);

                // Check if this content type is still published
                if (!publisher.IsPublished(newCt))
                {
                    Console.WriteLine(newCTName + " is not a published content type.");
                }
            }
            else
            {
                // The provided site is not a valid hub site
                Console.WriteLine("This site is not a valid hub site");
            }

        }
    }
}

Seguridad para subprocesos

Los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancias sean seguros para los subprocesos.

Vea también

Referencia

Miembros ContentTypePublisher

Espacio de nombres Microsoft.SharePoint.Taxonomy.ContentTypeSync