Exemple #1
0
        private bool HasMatch(BrowserCollection browsers, string strAgent, string strBrowser, double dblVersion)
        {
            bool _hasMatch = false;

            //Parse through the browsers to find a match based on name/minversion
            foreach (Browser browser in browsers)
            {
                //Check by browser name and min version
                if (!(string.IsNullOrEmpty(browser.Name)) && browser.Name.ToLower().Equals(strBrowser.ToLower()) && browser.MinVersion <= dblVersion)
                {
                    _hasMatch = true;
                    break;
                }

                //Check for special browser name of "*"
                if (browser.Name == "*")
                {
                    _hasMatch = true;
                    break;
                }
            }

            if (!_hasMatch)
            {
                //Parse through the browsers to find a match based on contains (more expensive so only try if NoMatch
                foreach (Browser browser in browsers)
                {
                    //Check if UserAgent contains the string (Contains)
                    if (!(string.IsNullOrEmpty(browser.Contains)))
                    {
                        if (strAgent.ToLower().IndexOf(browser.Contains.ToLower()) > -1)
                        {
                            _hasMatch = true;
                            break;
                        }
                    }
                }
            }

            return(_hasMatch);
        }
        private bool HasMatch(BrowserCollection browsers, string strAgent, string strBrowser, double dblVersion)
        {
            bool _hasMatch = false;

            //Parse through the browsers to find a match based on name/minversion
            foreach (Browser browser in browsers)
            {
                //Check by browser name and min version
                if (! (string.IsNullOrEmpty(browser.Name)) && browser.Name.ToLower().Equals(strBrowser.ToLower()) && browser.MinVersion <= dblVersion)
                {
                    _hasMatch = true;
                    break;
                }

                //Check for special browser name of "*"
                if (browser.Name == "*")
                {
                    _hasMatch = true;
                    break;
                }
            }

            if (! _hasMatch)
            {
                //Parse through the browsers to find a match based on contains (more expensive so only try if NoMatch
                foreach (Browser browser in browsers)
                {
                    //Check if UserAgent contains the string (Contains)
                    if (! (string.IsNullOrEmpty(browser.Contains)))
                    {
                        if (strAgent.ToLower().IndexOf(browser.Contains.ToLower()) > -1)
                        {
                            _hasMatch = true;
                            break;
                        }
                    }
                }
            }

            return _hasMatch;
        }