protected override void InternalProcessRecord() { bool test = false; ShouldProcessReason reason; if (!base.ShouldProcess(null, null, null, out reason)) { if (reason == ShouldProcessReason.WhatIf) { test = true; } } switch (ParameterSetName) { case "WebApplication": SPWebApplication webApp1 = WebApplication.Read(); _itemsPublisher.Publish(webApp1, test, Comment, TakeOverFilesWithNoCheckIn, FilterExpression); break; case "Site": using (SPSite site = Site.Read()) { _itemsPublisher.Publish(site, test, Comment, TakeOverFilesWithNoCheckIn, FilterExpression); } break; case "Web": using (SPWeb web = Web.Read()) { try { _itemsPublisher.Publish(web, test, Comment, TakeOverFilesWithNoCheckIn, FilterExpression); } finally { web.Site.Dispose(); } } break; case "List": SPList list = List.Read(); try { _itemsPublisher.Publish(list, test, Comment, TakeOverFilesWithNoCheckIn, FilterExpression); } finally { list.ParentWeb.Dispose(); list.ParentWeb.Site.Dispose(); } break; case "ListItem": SPListItem item = null; if (ParentList != null) { list = ParentList.Read(); item = ListItem.Read(list); } else { item = ListItem.Read(); } try { _itemsPublisher.Publish(item, test, Comment); } finally { item.ParentList.ParentWeb.Dispose(); item.ParentList.ParentWeb.Site.Dispose(); } break; default: foreach (SPService svc in Farm.Read().Services) { if (!(svc is SPWebService)) { continue; } foreach (SPWebApplication webApp2 in ((SPWebService)svc).WebApplications) { _itemsPublisher.Publish(webApp2, test, Comment, TakeOverFilesWithNoCheckIn, FilterExpression); } } break; } }