Example #1
0
 internal UpdatableHelpVersion(string version)
 {
     this.NormalizedVersionNumber = string.Empty;
     this.ElementIntValues        = new int[4];
     string[] array  = new string[4];
     string[] array2 = version.Split(new char[]
     {
         '.'
     });
     if (array2.Length == 4)
     {
         for (int i = 0; i < 4; i++)
         {
             string s = array2[i];
             if (!int.TryParse(s, out this.ElementIntValues[i]) || this.ElementIntValues[i] >= UpdatableHelpVersion.ElementUpperBound[i])
             {
                 throw new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateInvalidVersionNumberErrorID, UpdatableHelpStrings.UpdateInvalidVersionNumber(new LocalizedString(version)), ErrorCategory.InvalidData, null, null);
             }
             array[i] = this.ElementIntValues[i].ToString().PadLeft(UpdatableHelpVersion.ElementDigits[i], '0');
         }
         this.NormalizedVersionNumber = string.Join(".", array);
         return;
     }
     throw new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateInvalidVersionNumberErrorID, UpdatableHelpStrings.UpdateInvalidVersionNumber(new LocalizedString(version)), ErrorCategory.InvalidData, null, null);
 }
Example #2
0
        internal UpdatableHelpVersionRange ParseManifestForApplicableUpdates(string xml, UpdatableHelpVersion currentVersion, int currentRevision)
        {
            UpdatableHelpVersionRange result = null;
            XmlDocument xmlDocument          = null;

            try
            {
                xmlDocument = this.CreateValidXmlDocument(xml, new ValidationEventHandler(this.ManifestValidationHandler), true);
            }
            catch (XmlException innerException)
            {
                throw new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateManifestXmlValidationFailureErrorID, UpdatableHelpStrings.UpdateManifestXmlValidationFailure, ErrorCategory.InvalidData, null, innerException);
            }
            new SortedList <int, UpdatableHelpVersion>();
            XmlNodeList childNodes = xmlDocument["ExchangeHelpInfo"]["HelpVersions"].ChildNodes;

            foreach (object obj in childNodes)
            {
                XmlNode xmlNode = (XmlNode)obj;
                if (xmlNode.HasChildNodes)
                {
                    List <string> list       = new List <string>();
                    string        text       = string.Empty;
                    string        cabinetUrl = string.Empty;
                    int           num        = 0;
                    foreach (object obj2 in xmlNode.ChildNodes)
                    {
                        XmlNode xmlNode2 = (XmlNode)obj2;
                        string  name;
                        if ((name = xmlNode2.Name) != null)
                        {
                            if (!(name == "Version"))
                            {
                                if (!(name == "Revision"))
                                {
                                    if (!(name == "CulturesUpdated"))
                                    {
                                        if (name == "CabinetUrl")
                                        {
                                            cabinetUrl = xmlNode["CabinetUrl"].InnerText;
                                        }
                                    }
                                    else
                                    {
                                        text = xmlNode2.InnerText;
                                    }
                                }
                                else if (!int.TryParse(xmlNode2.InnerText, out num))
                                {
                                    throw new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateInvalidVersionNumberErrorID, UpdatableHelpStrings.UpdateInvalidVersionNumber(xmlNode2.InnerText), ErrorCategory.InvalidData, null, null);
                                }
                            }
                            else
                            {
                                list.Add(xmlNode2.InnerText.Trim());
                            }
                        }
                    }
                    int newestRevisionFound = currentRevision;
                    if (list.Count > 0 && num > 0 && !string.IsNullOrEmpty(text) && !string.IsNullOrEmpty("CabinetUrl"))
                    {
                        foreach (string versionRange in list)
                        {
                            UpdatableHelpVersionRange updatableHelpVersionRange = new UpdatableHelpVersionRange(versionRange, num, text, cabinetUrl);
                            if (updatableHelpVersionRange.IsInRangeAndNewerThan(currentVersion, newestRevisionFound))
                            {
                                result = updatableHelpVersionRange;
                                newestRevisionFound = updatableHelpVersionRange.HelpRevision;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Example #3
0
        internal UpdatableHelpVersionRange(string versionRange, int revision, string culturesUpdated, string cabinetUrl)
        {
            string[] array = versionRange.Split(new char[]
            {
                '-'
            });
            if (array == null || array.Length < 1 || array.Length > 2)
            {
                throw new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateInvalidVersionNumberErrorID, UpdatableHelpStrings.UpdateInvalidVersionNumber(new LocalizedString(versionRange)), ErrorCategory.InvalidData, null, null);
            }
            this.StartVersion = new UpdatableHelpVersion(array[0].Trim());
            this.EndVersion   = ((array.Length == 2) ? new UpdatableHelpVersion(array[1].Trim()) : this.StartVersion);
            if (this.CompareVersions(this.StartVersion, this.EndVersion) > 0)
            {
                UpdatableHelpVersion startVersion = this.StartVersion;
                this.StartVersion = this.EndVersion;
                this.EndVersion   = startVersion;
            }
            this.HelpRevision = revision;
            this.CabinetUrl   = cabinetUrl;
            string[] array2 = culturesUpdated.Split(new char[]
            {
                ','
            }, StringSplitOptions.RemoveEmptyEntries);
            List <string> list = new List <string>();

            if (array2 != null)
            {
                foreach (string text in array2)
                {
                    list.Add(text.Trim().ToLower());
                }
            }
            this.CulturesAffected = list.ToArray();
        }