Пример #1
0
        /// <summary>
        ///     Parses the actual XML Elements from the file and determines if it is supported.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns>True if the browser information is supported based on the data in the XML file otherwise false.</returns>
        /// <exception cref="System.Exception">
        ///     Error in SupportedBrowsers.xml file.
        /// </exception>
        private bool IsSupportedVersionInData(IEnumerable <XElement> data)
        {
            foreach (var el in data)
            {
                var minVersionAtt  = el.Attribute("MinVersion");
                var maxVersionAtt  = el.Attribute("MaxVersion");
                var machineTypeAtt = el.Attribute("MachineType");

                if (minVersionAtt == null || maxVersionAtt == null || machineTypeAtt == null)
                {
                    throw new Exception("Error in SupportedBrowsers.xml file.");
                }

                try
                {
                    if (Version >= double.Parse(minVersionAtt.Value) &&
                        Version <= double.Parse(maxVersionAtt.Value) &&
                        machineTypeAtt.Value.ToUpper().Contains(MachineType.ToUpper()))
                    {
                        return(true);
                    }
                }
                catch (Exception)
                {
                    throw new Exception("Error in SupportedBrowsers.xml file.");
                }
            }
            return(false);
        }