/// <summary>
        /// Check if the browser user agent string matches this rule.
        /// </summary>
        private bool MatchRule(BrowserInfo browserInfo, BrowserRule browserRule)
        {
            // check if OS name matches ('*' will be Unknown, which means skip this check)
            if (browserRule.OSName != BrowserOS.Unknown &&
                browserInfo.OSName != browserRule.OSName)
            {
                return(false);
            }

            // check if OS meets minimum version (0 means skip this check)
            if (browserRule.OSMinVersion > 0 &&
                browserInfo.OSVersion < browserRule.OSMinVersion)
            {
                return(false);
            }

            // check if OS meets maximum version (0 means skip this check)
            if (browserRule.OSMaxVersion > 0 &&
                browserInfo.OSVersion > browserRule.OSMaxVersion)
            {
                return(false);
            }

            // check if the hardware architecture matches ('*' means skip this check)
            if (browserRule.Architecture != WILDCARD &&
                browserInfo.Architecture != browserRule.Architecture)
            {
                return(false);
            }

            // check if the browser name matches ('*' means skip this check)
            if (browserRule.Name != WILDCARD &&
                browserInfo.Name != browserRule.Name)
            {
                return(false);
            }

            // check if browser meets minimum version (0 means skip this check)
            if (browserRule.MinVersion > 0 &&
                browserInfo.Version < browserRule.MinVersion)
            {
                return(false);
            }

            // check if browser meets maximum version (0 means skip this check)
            if (browserRule.MaxVersion > 0 &&
                browserInfo.Version > browserRule.MaxVersion)
            {
                return(false);
            }

            // everything matched
            return(true);
        }
 public void AddRule(BrowserRule browserRule)
 {
     _rules.Add(browserRule);
 }
        /// <summary>
        /// Check the action for this user agent string.
        /// </summary>
        public BrowserAction Check(BrowserInfo browserInfo)
        {
            BrowserRule browserRule = FindRule(browserInfo);

            return((browserRule != null) ? browserRule.Action : BrowserAction.Deny);
        }