Content Type Syndication helps ensure uniformity across lists so that they use the same content types, and therefore the same columns. In Microsoft Office SharePoint Server 2007, a content type is set at the site-collection level. By using content type syndication in Microsoft SharePoint Server 2010, a content type can be shared within the farm or outside the farm with the managed metadata service application.

You can use the object model to customize content type syndication to create a new content type, publish it, and unpublish it. The following code example introduces the ContentTypePublisher class. After a managed metadata service application and its proxy are provisioned and a site is designated as the hub on the service application, use this class to publish or unpublish the content types on the hub site. Also, use this class to verify whether a content type on this hub site is published, and to verify whether the Metadata Hub feature is enabled on the hub.

In many scenarios, a hub acts as a publisher, and Web applications or site collections subscribe to the content that the hub publishes. When a content type is published, subscribers pull content types down through a timer job. Users navigate to the Central Administration page, where they can select a Web application as a hub. Individual Web applications can also subscribe to the selected hub as their provider for shared application data, including content types.

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
{
publicstaticclass ContentTypeSyndicationSamples
{
/// Demostrates how to use the ContentTypePublisher class by creating a /// content type and then publishing it and unpublishing it./// Before this method is called, a Managed Metadata service application/// should be created and a hub should be designated on the service application.///<param name="hubSite">/// The site that is designated as the hub.///</param>publicstaticvoid UseContentTypePublisher(SPSite hubSite)
{
// Get the root Web of the site.
SPWeb rootWeb = hubSite.RootWeb;
// Create a new content type based on the 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 to see whether 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 to see whether 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 whether this content type is still publishedif (!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");
}
}
}
}