public static void ProcessLegacySkinControls()
 {
     foreach (SkinControlInfo skinControl in SkinControlController.GetSkinControls().Values)
     {
         if (skinControl.PackageID == Null.NullInteger)
         {
             try
             {
                 PackageInfo package = new PackageInfo(new InstallerInfo());
                 package.Name = skinControl.ControlKey;
                 package.FriendlyName = skinControl.ControlKey;
                 package.Description = Null.NullString;
                 package.Version = new Version(1, 0, 0);
                 package.PackageType = "SkinObject";
                 ParsePackageName(package);
                 SkinControlPackageWriter skinControlWriter = new SkinControlPackageWriter(skinControl, package);
                 package.Manifest = skinControlWriter.WriteManifest(true);
                 PackageController.SavePackage(package);
                 skinControl.PackageID = package.PackageID;
                 SkinControlController.SaveSkinControl(skinControl);
             }
             catch (Exception ex)
             {
                 ex.ToString();
             }
         }
     }
 }
        private void ReadManifest(Stream stream)
        {
            XPathDocument doc = new XPathDocument(stream);
            XPathNavigator rootNav = doc.CreateNavigator();
            XPathDocument legacyDoc = null;
            rootNav.MoveToFirstChild();
            string packageType = Null.NullString;
            string legacyManifest = Null.NullString;
            if (rootNav.Name == "CommonLibrary")
            {
                packageType = Util.ReadAttribute(rootNav, "type");
            }
            else if (rootNav.Name.ToLower() == "languagepack")
            {
                packageType = "LanguagePack";
            }
            else
            {
                InstallerInfo.Log.AddFailure(Util.PACKAGE_UnRecognizable);
            }
            switch (packageType.ToLower())
            {
                case "package":
                    InstallerInfo.IsLegacyMode = false;
                    ProcessPackages(rootNav);
                    break;
                case "module":
                    InstallerInfo.IsLegacyMode = true;
                    StringBuilder sb = new StringBuilder();
                    XmlWriter writer = XmlWriter.Create(sb, XmlUtils.GetXmlWriterSettings(ConformanceLevel.Fragment));
                    PackageWriterBase.WriteManifestStartElement(writer);
                    foreach (XPathNavigator folderNav in rootNav.Select("folders/folder"))
                    {
                        ModulePackageWriter modulewriter = new ModulePackageWriter(folderNav, InstallerInfo);
                        modulewriter.WriteManifest(writer, true);
                    }

                    PackageWriterBase.WriteManifestEndElement(writer);
                    writer.Close();
                    legacyDoc = new XPathDocument(new StringReader(sb.ToString()));
                    ProcessPackages(legacyDoc.CreateNavigator().SelectSingleNode("CommonLibrary"));
                    break;
                case "languagepack":
                    InstallerInfo.IsLegacyMode = true;
                    LanguagePackWriter languageWriter = new LanguagePackWriter(rootNav, InstallerInfo);
                    LegacyError = languageWriter.LegacyError;
                    if (string.IsNullOrEmpty(LegacyError))
                    {
                        legacyManifest = languageWriter.WriteManifest(false);
                        legacyDoc = new XPathDocument(new StringReader(legacyManifest));
                        ProcessPackages(legacyDoc.CreateNavigator().SelectSingleNode("CommonLibrary"));
                    }
                    break;
                case "skinobject":
                    InstallerInfo.IsLegacyMode = true;
                    SkinControlPackageWriter skinControlwriter = new SkinControlPackageWriter(rootNav, InstallerInfo);
                    legacyManifest = skinControlwriter.WriteManifest(false);
                    legacyDoc = new XPathDocument(new StringReader(legacyManifest));
                    ProcessPackages(legacyDoc.CreateNavigator().SelectSingleNode("CommonLibrary"));
                    break;
            }
        }