Microsoft version: http://msdn.microsoft.com/en-us/library/gg447066.aspx
To uninstall a feature go to Microsfot SharePoint 2010 Products -> SharePoint 2010 Management Shell
uninstall-SPFeature
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
namespace Branding.Features.Feature1
{
///
/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
///
///
/// The GUID attached to this class may be used during packaging and should not be modified.
///
[Guid("18aee99d-0efa-4fe3-91c1-6fd688e7f05c")]
public class Feature1EventReceiver : SPFeatureReceiver
{
public override void FeatureActivated(
SPFeatureReceiverProperties properties)
{
SPSite siteCollection = properties.Feature.Parent as SPSite;
if (siteCollection != null)
{
SPWeb topLevelSite = siteCollection.RootWeb;
// Calculate relative path to site from Web Application root.
string WebAppRelativePath = topLevelSite.ServerRelativeUrl;
if (!WebAppRelativePath.EndsWith("/"))
{
WebAppRelativePath += "/";
}
// Enumerate through each site and apply branding.
foreach (SPWeb site in siteCollection.AllWebs)
{
site.MasterUrl = WebAppRelativePath +
"_catalogs/masterpage/v4_508.master";
site.CustomMasterUrl = WebAppRelativePath +
"_catalogs/masterpage/v4_508.master";
site.UIVersion = 4;
site.Update();
}
}
}
public override void FeatureDeactivating(
SPFeatureReceiverProperties properties) {
SPSite siteCollection = properties.Feature.Parent as SPSite;
if (siteCollection != null) {
SPWeb topLevelSite = siteCollection.RootWeb;
// Calculate relative path of site from Web Application root.
string WebAppRelativePath = topLevelSite.ServerRelativeUrl;
if (!WebAppRelativePath.EndsWith("/")) {
WebAppRelativePath += "/";
} // Enumerate through each site and remove custom branding.
foreach (SPWeb site in siteCollection.AllWebs) {
site.MasterUrl = WebAppRelativePath +
"_catalogs/masterpage/v4.master";
site.CustomMasterUrl = WebAppRelativePath +
"_catalogs/masterpage/v4.master";
site.AlternateCssUrl = "";
site.SiteLogoUrl = "";
site.Update();
}
}
}
}
}