示例#1
0
        internal UpdatableHelpVersionRange SearchManifestForApplicableUpdates(UpdatableHelpVersion currentVersion, int currentRevision)
        {
            StreamReader streamReader = new StreamReader(this.helpUpdater.LocalManifestPath);
            string       xml          = streamReader.ReadToEnd();

            streamReader.Close();
            HelpSchema helpSchema = new HelpSchema();

            return(helpSchema.ParseManifestForApplicableUpdates(xml, currentVersion, currentRevision));
        }
示例#2
0
        internal Dictionary <string, LocalizedString> ValidateFiles()
        {
            Dictionary <string, LocalizedString> dictionary = new Dictionary <string, LocalizedString>();
            string text = this.LoadFileAsString(this.helpUpdater.PowerShellPsmamlSchemaFilePath);

            if (!string.IsNullOrEmpty(text))
            {
                HelpSchema helpSchema = new HelpSchema("http://schemas.microsoft.com/maml/2004/10", text);
                string     localCabinetExtractionTargetPath = this.helpUpdater.LocalCabinetExtractionTargetPath;
                string     text2 = null;
                int        num   = 0;
                foreach (KeyValuePair <string, List <string> > keyValuePair in this.cabinetFiles)
                {
                    if (this.helpUpdater.Cmdlet.Abort)
                    {
                        return(null);
                    }
                    if (!keyValuePair.Key.Equals(text2))
                    {
                        text2 = keyValuePair.Key;
                    }
                    foreach (string text3 in keyValuePair.Value)
                    {
                        if (this.helpUpdater.Cmdlet.Abort)
                        {
                            return(null);
                        }
                        this.helpUpdater.UpdateProgress(UpdatePhase.Validating, new LocalizedString(text3), ++num, this.filesAffected);
                        string text4 = Path.GetExtension(text3).ToLower();
                        string text5 = text2 + text3;
                        string path  = localCabinetExtractionTargetPath + text5;
                        if (File.Exists(path))
                        {
                            if (text4.Equals(".xml"))
                            {
                                string      s           = this.LoadFileAsString(path);
                                XmlReader   reader      = XmlReader.Create(new StringReader(s));
                                XmlDocument xmlDocument = new XmlDocument();
                                XmlNode     xmlNode     = null;
                                xmlDocument.Load(reader);
                                if (xmlDocument.HasChildNodes)
                                {
                                    bool flag = false;
                                    foreach (object obj in xmlDocument.ChildNodes)
                                    {
                                        XmlNode xmlNode2 = (XmlNode)obj;
                                        if (xmlNode2.LocalName.Equals("helpitems", StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            if (xmlNode != null)
                                            {
                                                flag = true;
                                                break;
                                            }
                                            xmlNode = xmlNode2;
                                        }
                                    }
                                    if (flag)
                                    {
                                        dictionary.Add(text5, UpdatableHelpStrings.UpdateMultipleHelpItems);
                                        continue;
                                    }
                                }
                                if (xmlNode != null)
                                {
                                    for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                                    {
                                        XmlNode xmlNode3 = xmlNode.ChildNodes[i];
                                        if (xmlNode3.NodeType == XmlNodeType.Element && !xmlNode3.LocalName.StartsWith("_"))
                                        {
                                            if (!xmlNode3.LocalName.Equals("providerHelp", StringComparison.OrdinalIgnoreCase))
                                            {
                                                if (xmlNode3.LocalName.Equals("para", StringComparison.OrdinalIgnoreCase))
                                                {
                                                    if (!xmlNode3.NamespaceURI.Equals("http://schemas.microsoft.com/maml/2004/10", StringComparison.OrdinalIgnoreCase))
                                                    {
                                                        dictionary.Add(text5, UpdatableHelpStrings.UpdateInvalidXmlNamespace("http://schemas.microsoft.com/maml/2004/10"));
                                                        break;
                                                    }
                                                    goto IL_2DD;
                                                }
                                                else if (!xmlNode3.NamespaceURI.Equals("http://schemas.microsoft.com/maml/dev/command/2004/10", StringComparison.OrdinalIgnoreCase))
                                                {
                                                    dictionary.Add(text5, UpdatableHelpStrings.UpdateInvalidXmlNamespace("http://schemas.microsoft.com/maml/2004/10"));
                                                    break;
                                                }
                                            }
                                            if (this.helpUpdater.Cmdlet.Abort)
                                            {
                                                return(null);
                                            }
                                            try
                                            {
                                                helpSchema.CreateValidXmlDocument(xmlNode3.OuterXml, new ValidationEventHandler(this.ContentValidationHandler), false);
                                            }
                                            catch
                                            {
                                                dictionary.Add(text5, UpdatableHelpStrings.UpdateInvalidXml);
                                            }
                                        }
                                        IL_2DD :;
                                    }
                                }
                                else
                                {
                                    dictionary.Add(text5, UpdatableHelpStrings.UpdateInvalidXmlRoot);
                                }
                            }
                            else
                            {
                                if (text4.Equals(".txt"))
                                {
                                    FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
                                    try
                                    {
                                        if (fileStream.Length > 2L)
                                        {
                                            byte[] array = new byte[2];
                                            fileStream.Read(array, 0, 2);
                                            if (array[0] == 77 && array[1] == 90)
                                            {
                                                dictionary.Add(text5, UpdatableHelpStrings.UpdateInvalidTextCharacters);
                                            }
                                        }
                                        continue;
                                    }
                                    finally
                                    {
                                        fileStream.Close();
                                    }
                                }
                                dictionary.Add(text5, UpdatableHelpStrings.UpdateUnsupportedFileType);
                            }
                        }
                        else
                        {
                            dictionary.Add(text2 + text3, UpdatableHelpStrings.UpdateFileNotFound);
                        }
                    }
                }
                return(dictionary);
            }
            return(dictionary);
        }