private static Dictionary <string, string> GetWebPartProperties(ISharePointCommandContext context,
                                                                        WebPartNodeInfo nodeInfo)
        {
            SPList     webParts = context.Site.GetCatalog(SPListTemplateType.WebPartCatalog);
            SPListItem webPart  = webParts.Items[nodeInfo.UniqueId];

            return(SharePointCommandServices.GetProperties(webPart));
        }
        private static WebPartNodeInfo[] GetWebParts(ISharePointCommandContext context)
        {
            var nodeInfos = new List <WebPartNodeInfo>();
            SPListItemCollection webParts = context.Site.GetCatalog(
                SPListTemplateType.WebPartCatalog).Items;

            foreach (SPListItem webPart in webParts)
            {
                WebPartNodeInfo nodeInfo = new WebPartNodeInfo
                {
                    Id       = webPart.ID,
                    SiteId   = webPart.ParentList.ParentWeb.ID,
                    Name     = webPart.Title,
                    UniqueId = webPart.UniqueId,
                    ImageUrl = webPart.ParentList.ImageUrl
                };
                nodeInfos.Add(nodeInfo);
            }

            return(nodeInfos.ToArray());
        }