public static void AddInternalItems(DTE dte, List<NameValueItem> _list, string internalXPath, string internalNamespace, XmlNodeHandler nodeHandler, string extension)
 {
     nodeHandler.SetGroupName(SPSFConstants.ThisSolutionNodeText);
       nodeHandler.SetGlobalResourcesDictionary(Helpers.GetResourcesInSolution(dte));
       if (dte != null)
       {
     foreach (Project project in dte.Solution.Projects)
     {
       Helpers.NavigateProjectItems(project.ProjectItems, _list, internalXPath, internalNamespace, nodeHandler, extension);
     }
       }
 }
        public static void AddExternalItems(DTE dte, List<NameValueItem> _list, string internalXPath, string internalNamespace, XmlNodeHandler nodeHandler)
        {
            string configfilename = "";

            if (dte != null)
            {
                string solutionpath = dte.Solution.FullName;
                solutionpath = solutionpath.Substring(0, solutionpath.LastIndexOf("\\"));

                configfilename = Path.Combine(solutionpath, "SharepointConfiguration.xml");

                if (!File.Exists(configfilename))
                {
                    //SharePointConfiguration not found at expected place
                    configfilename = Helpers.GetBasePath() + @"\Templates\Text\SharePointConfiguration.xml";
                }

                if (!File.Exists(configfilename))
                {
                    if (MessageBox.Show("No file 'SharePointConfiguration.xml' found in solution. This file contains a list of all feature, content types, list templates etc. in the target system. " + Environment.NewLine + "Do you want to create this file from your local SharePoint instalation?", "SharePoint Configuration", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        SharePointConfigurationHelper.CreateSharePointConfigurationFile(dte);
                        configfilename = Path.Combine(solutionpath, "SharepointConfiguration.xml");
                    }
                }

                if (File.Exists(configfilename))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(configfilename);

                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
                    nsmgr.AddNamespace("ns", internalNamespace);
                    foreach (XmlNode node in doc.SelectNodes(internalXPath, nsmgr))
                    {
                        foreach(NameValueItem nvitem in nodeHandler.GetNameValueItems(node, null, null))
                        {
                            if (nvitem != null)
                            {
                                _list.Add(nvitem);
                            }
                        }
                    }
                }
                else
                {

                }
            }
        }
 public static void AddInternalItems(DTE dte, bool startFromSelecteditem, List<NameValueItem> _list, string internalXPath, string internalNamespace, XmlNodeHandler nodeHandler)
 {
     nodeHandler.SetGroupName(SPSFConstants.ThisSolutionNodeText);
     nodeHandler.SetGlobalResourcesDictionary(Helpers.GetResourcesInSolution(dte));
     if (dte != null)
     {
         if (startFromSelecteditem)
         {
             if (dte.SelectedItems.Count > 0)
             {
                 try
                 {
                     SelectedItem item = dte.SelectedItems.Item(1);
                     if (item.ProjectItem != null)
                     {
                         Helpers.NavigateProjectItem(item.ProjectItem, _list, internalXPath, internalNamespace, nodeHandler, ".xml");
                     }
                     else if (item.Project != null)
                     {
                         Helpers.NavigateProjectItems(item.Project.ProjectItems, _list, internalXPath, internalNamespace, nodeHandler, ".xml");
                     }
                 }
                 catch { }
             }
         }
         else
         {
             foreach (Project project in dte.Solution.Projects)
             {
                 Helpers.NavigateProjectItems(project.ProjectItems, _list, internalXPath, internalNamespace, nodeHandler, ".xml");
             }
         }
     }
 }
 public static void AddInternalItems(DTE dte, List<NameValueItem> _list, string internalXPath, string internalNamespace, XmlNodeHandler nodeHandler)
 {
     AddInternalItems(dte, _list, internalXPath, internalNamespace, nodeHandler, ".xml");
 }
        /// <summary>
        /// searches 
        /// </summary>
        /// <param name="projectitems"></param>
        /// <param name="_list"></param>
        /// <param name="internalXPath"></param>
        /// <param name="internalNamespace"></param>
        /// <param name="nodeHandler"></param>
        public static void NavigateProjectItems(ProjectItems projectitems, List<NameValueItem> _list, string internalXPath, string internalNamespace, XmlNodeHandler nodeHandler, string fileExtension)
        {
            if (projectitems != null)
            {
                foreach (ProjectItem item in projectitems)
                {
                    NavigateProjectItem(item, _list, internalXPath, internalNamespace, nodeHandler, fileExtension);


                }
            }
        }
        public static void NavigateProjectItem(ProjectItem item, List<NameValueItem> _list, string internalXPath, string internalNamespace, XmlNodeHandler nodeHandler, string fileExtension)
        {
            if (item.Name.ToLower().EndsWith(fileExtension))
            {
                try
                {
                    string path = GetFullPathOfProjectItem(item);

                    XmlDocument doc = new XmlDocument();
                    doc.Load(path);

                    XmlNodeList foundnodes = null;

                    if (internalNamespace != "")
                    {
                        XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
                        nsmgr.AddNamespace("ns", internalNamespace);
                        foundnodes = doc.SelectNodes(internalXPath, nsmgr);
                    }
                    else
                    {
                        foundnodes = doc.SelectNodes(internalXPath);
                    }

                    XmlDocument resourceDoc = null;
                    if (foundnodes.Count > 0)
                    {
                        //jetzt macht es sinn auch das zugehörige Resourcefile zu suchen
                        //suche das XmlDocument mit den Resourcen für das aktuelle Feature
                        //1. könnte ein feature sein, dann sind die daten im Features/Feature1/Resources/Resources.resx
                        //2. könnte eine sitedefinition sein, dann in 12/Resources suchen
                        try
                        {
                            ProjectItem featurefolder = GetFeatureFolderByProjectItem(item);
                            if (featurefolder != null)
                            {
                                ProjectItem resourceitem = GetProjectItemByName(GetProjectItemByName(featurefolder.ProjectItems, "Resources").ProjectItems, "Resources.resx");
                                if (resourceitem != null)
                                {
                                    string respath = Helpers.GetFullPathOfProjectItem(resourceitem);
                                    resourceDoc = new XmlDocument();
                                    resourceDoc.Load(respath);
                                }
                            }
                        }
                        catch (Exception)
                        {
                            //no resource document found
                        }
                    }
                    foreach (XmlNode node in foundnodes)
                    {

                        foreach (NameValueItem nvitem in nodeHandler.GetNameValueItems(node, resourceDoc, item))
                        {
                            if (nvitem != null)
                            {
                                _list.Add(nvitem);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            if (item.Object is Project)
            {
                Project p = item.Object as Project;
                NavigateProjectItems(p.ProjectItems, _list, internalXPath, internalNamespace, nodeHandler, fileExtension);
            }
            else
            {
                if (item.ProjectItems != null)
                {
                    if (item.ProjectItems.Count > 0)
                    {
                        NavigateProjectItems(item.ProjectItems, _list, internalXPath, internalNamespace, nodeHandler, fileExtension);
                    }
                }
            }
        }