Last active
December 17, 2015 13:10
-
-
Save vgrem/5615437 to your computer and use it in GitHub Desktop.
CS-Script: reference another C# script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//css_host /version:v3.5 /platform:x64; | |
//css_dir C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI; | |
//css_import WebPartManagerExtensions; | |
using System; | |
using Microsoft.SharePoint; | |
using Microsoft.SharePoint.WebPartPages; | |
namespace CSScript4SP | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using (var site = new SPSite("http://intranet.contoso.com")) | |
{ | |
using (var web = site.OpenWeb()) | |
{ | |
web.ForEachWebPartOnPage<Microsoft.SharePoint.WebPartPages.WebPart>("/en/Pages/default.aspx",PrintWebPartInfo); | |
} | |
} | |
} | |
private static void PrintWebPartInfo(SPWeb web, Microsoft.SharePoint.WebPartPages.WebPart webPart, SPLimitedWebPartManager wpm) | |
{ | |
Console.WriteLine("{0} {1} {2} {3}", webPart.Title, webPart.GetType().Name, webPart.ZoneIndex, webPart.ZoneID); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment