Identified OperatingSystem model object.
Inheritance: BuiltObject, IComparable, ICloneable
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();
            model.majorRevision = "-";
            model.SetVendor("-");
            model.SetModel("Linux");

            int confidence = 60;

            if (descriptionRegex.IsMatch(userAgent.GetPatternElementsInside()))
            {
                Match descriptionMatcher = descriptionRegex.Match(userAgent.GetPatternElementsInside());
                GroupCollection groups = descriptionMatcher.Groups;

                if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                {
                    confidence += 10;
                }
                if (groups[2] != null && groups[2].Value.Trim().Length > 0)
                {
                    model.SetDescription(groups[2].Value);
                    confidence += 10;
                }
            }

            model.confidence = confidence;

            return model;
        }
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();

            model.SetVendor("Research In Motion");
            model.SetModel("Black Berry OS");
            model.majorRevision = "1";

            if (versionRegex.IsMatch(userAgent.completeUserAgent))
            {
                Match versionMatcher = versionRegex.Match(userAgent.completeUserAgent);
                GroupCollection groups = versionMatcher.Groups;

                if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                {
                    model.confidence = 50;
                    model.SetVersion(groups[1].Value);

                    if (groups[2] != null && groups[2].Value.Trim().Length > 0)
                    {
                        model.majorRevision = groups[2].Value;
                        model.confidence = 60;
                    }

                    if (groups[3] != null && groups[3].Value.Trim().Length > 0)
                    {
                        model.minorRevision = groups[3].Value;
                        model.confidence = 70;
                    }

                    if (groups[4] != null && groups[4].Value.Trim().Length > 0)
                    {
                        model.microRevision = groups[4].Value;
                        model.confidence = 80;
                    }

                    if (groups[5] != null && groups[5].Value.Trim().Length > 0)
                    {
                        model.nanoRevision = groups[5].Value;
                        model.confidence = 90;
                    }
                }
            }
            return model;
        }
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();
            model.majorRevision = "1";
            model.SetVendor("Palm");
            model.SetModel("Web OS");
            model.confidence = 40;

            string patternElementsInside = userAgent.GetPatternElementsInside();
            String[] splittedTokens = patternElementsInside.Split(";".ToCharArray());

            foreach (String tokenElement in splittedTokens)
            {
                if (versionRegex.IsMatch(tokenElement))
                {
                    Match versionMatcher = versionRegex.Match(tokenElement);
                    GroupCollection groups = versionMatcher.Groups;

                    model.confidence = 90;
                    if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                    {
                        model.SetVersion(groups[1].Value);
                    }
                    if (groups[2] != null && groups[2].Value.Trim().Length > 0)
                    {
                        model.majorRevision = groups[2].Value;
                    }
                    if (groups[3] != null && groups[3].Value.Trim().Length > 0)
                    {
                        model.minorRevision = groups[3].Value;
                    }
                    if (groups[4] != null && groups[4].Value.Trim().Length > 0)
                    {
                        model.microRevision = groups[4].Value;
                    }
                    if (groups[5] != null && groups[5].Value.Trim().Length > 0)
                    {
                        model.nanoRevision = groups[5].Value;
                    }
                }
            }
            return model;
        }
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();
            model.majorRevision = "-";
            model.SetVendor("Apple");
            model.SetModel("Mac OS X");

            int confidence = 60;

            if (versionRegex.IsMatch(userAgent.GetPatternElementsInside()))
            {
                Match versionMatcher = versionRegex.Match(userAgent.GetPatternElementsInside());
                GroupCollection groups = versionMatcher.Groups;

                model.confidence = 80;

                if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                {
                    model.SetVersion(groups[1].Value);
                }
                if (groups[2] != null && groups[2].Value.Trim().Length > 0)
                {
                    model.majorRevision = groups[2].Value;
                }
                if (groups[3] != null && groups[3].Value.Trim().Length > 0)
                {
                    model.minorRevision = groups[3].Value;
                }
                if (groups[4] != null && groups[4].Value.Trim().Length > 0)
                {
                    model.microRevision = groups[4].Value;
                }
            }

            model.confidence = confidence;

            return model;
        }
 /// <summary>
 /// When Evidence change, stored model object are removed in order to allow new identification. 
 /// </summary>
 /// <param name="key">Header name</param>
 /// <param name="value">Header value</param>
 public override void Put(String key, String value)
 {
     this.osFound = null;
     this.browserFound = null;
     base.Put(key, value);
 }
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();
            model.majorRevision = "1";
            model.SetVendor("Nokia");
            model.SetModel("Symbian OS");
            model.confidence = 40;

            string patternElementsInside = userAgent.GetPatternElementsInside();
            String[] splittedTokens = patternElementsInside.Split(";".ToCharArray());
            foreach (String tokenElement in splittedTokens)
            {
                if (versionRegex.IsMatch(tokenElement))
                {
                    Match versionMatcher = versionRegex.Match(tokenElement);
                    GroupCollection groups = versionMatcher.Groups;

                    model.SetDescription("Series60");
                    if (model.confidence > 40)
                    {
                        model.confidence = 100;

                    }
                    else
                    {
                        model.confidence = 90;
                    }

                    if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                    {
                        model.majorRevision = groups[1].Value;
                    }
                    if (groups[2] != null && groups[2].Value.Trim().Length > 0)
                    {
                        model.minorRevision = groups[2].Value;
                    }
                    if (groups[3] != null && groups[3].Value.Trim().Length > 0)
                    {
                        model.microRevision = groups[3].Value;
                    }
                }

                if (versionExtraRegex.IsMatch(tokenElement))
                {
                    Match versionExtraMatcher = versionExtraRegex.Match(tokenElement);
                    GroupCollection groups = versionExtraMatcher.Groups;

                    if (model.confidence > 40)
                    {
                        model.confidence = 100;

                    }
                    else
                    {
                        model.confidence = 85;
                    }

                    if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                    {
                        string groupValueTrimmed = groups[1].Value.Trim();
                        model.SetVersion(groupValueTrimmed);
                    }
                }
                //TODO: inference VERSION_EXTRA/VERSION_REGEXP and vice-versa
            }
            return model;
        }
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();
            model.SetVendor("Microsoft");
            model.SetModel("Windows Phone");
            model.confidence = 40;
            bool isInPostMoz = false;

            String toSplit = userAgent.GetPatternElementsInside();

            if (!versionRegex.IsMatch(toSplit))
            {
                toSplit = userAgent.GetPatternElementsPost();
                isInPostMoz = true;
            }

            String[] splittedTokens = toSplit.Split(";".ToCharArray());
            foreach (String tokenElement in splittedTokens)
            {
                if (versionRegex.IsMatch(tokenElement))
                {
                    Match versionMatcher = versionRegex.Match(tokenElement);
                    GroupCollection groups = versionMatcher.Groups;

                    if (isInPostMoz)
                    {
                        model.confidence = 85;

                    }
                    else
                    {
                        model.confidence = 90;
                    }

                    if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                    {
                        model.SetVersion(groups[1].Value);
                    }

                    if (groups[2] != null && groups[2].Value.Trim().Length > 0)
                    {
                        model.majorRevision = groups[2].Value;
                    }

                    if (groups[3] != null && groups[3].Value.Trim().Length > 0)
                    {
                        model.minorRevision = groups[3].Value;
                    }

                    if (groups[4] != null && groups[4].Value.Trim().Length > 0)
                    {
                        model.microRevision = groups[4].Value;
                    }

                    if (groups[5] != null && groups[5].Value.Trim().Length > 0)
                    {
                        model.nanoRevision = groups[5].Value;
                    }
                }

                if (model.majorRevision.Equals("0") && model.minorRevision.Equals("0"))
                {
                    model.majorRevision = "6";
                    model.minorRevision = "5";
                }
                model.SetDescription("Windows Phone " + model.majorRevision + "." + model.minorRevision + "." + model.microRevision + "." + model.nanoRevision);
            }
            return model;
        }
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();

            String rebuilded = userAgent.GetPatternElementsInside() + ";" + userAgent.GetPatternElementsPost();

            String[] splittedTokens = rebuilded.Split(";".ToCharArray());
            foreach (String tokenElement in splittedTokens)
            {
                if (versionRegex.IsMatch(tokenElement))
                {
                    Match versionMatcher = versionRegex.Match(tokenElement);
                    GroupCollection groups = versionMatcher.Groups;

                    if (groups[11].Value != null && groups[11].Value.Trim().Length > 0)
                    {
                        model.SetVendor("Research In Motion");
                        model.SetModel("RIM Tablet OS");
                        model.majorRevision = "1";
                        model.confidence = 50;

                        if (groups[11].Value != null && groups[11].Value.Trim().Length > 0)
                        {
                            model.SetVersion(groups[11].Value);

                        }

                        if (groups[12].Value != null && groups[12].Value.Trim().Length > 0)
                        {
                            model.majorRevision = groups[12].Value;
                            model.confidence = 60;

                        }

                        if (groups[13].Value != null && groups[13].Value.Trim().Length > 0)
                        {
                            model.minorRevision = groups[13].Value;
                            model.confidence = 70;

                        }

                        if (groups[14].Value != null && groups[14].Value.Trim().Length > 0)
                        {
                            model.microRevision = groups[14].Value;
                            model.confidence = 80;

                        }

                        if (groups[15].Value != null && groups[15].Value.Trim().Length > 0)
                        {
                            model.nanoRevision = groups[15].Value;
                            model.confidence = 90;

                        }
                        return model;

                    }
                    else if ((groups[1] != null && groups[1].Value.Trim().Length > 0) || (groups[6] != null && groups[6].Value.Trim().Length > 0))
                    {
                        model.SetVendor("Research In Motion");
                        model.SetModel("Black Berry OS");
                        model.majorRevision = "1";
                        model.confidence = 40;

                        if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                        {
                            if (groups[6] != null && groups[6].Value.Trim().Length > 0)
                            {
                                model.confidence = 100;

                            }
                            else
                            {
                                model.confidence = 80;
                            }

                        }
                        else if (groups[6] != null && groups[6].Value.Trim().Length > 0)
                        {
                            model.confidence = 90;
                        }

                        if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                        {
                            model.SetVersion(groups[1].Value);

                        }
                        else if (groups[6] != null && groups[6].Value.Trim().Length > 0)
                        {
                            model.SetVersion(groups[6].Value);
                        }

                        if (groups[2] != null && groups[2].Value.Trim().Length > 0)
                        {
                            model.majorRevision = groups[2].Value;

                        }
                        else if (groups[7] != null && groups[7].Value.Trim().Length > 0)
                        {
                            model.majorRevision = groups[7].Value;
                        }

                        if (groups[3] != null && groups[3].Value.Trim().Length > 0)
                        {
                            model.minorRevision = groups[3].Value;

                        }
                        else if (groups[8] != null && groups[8].Value.Trim().Length > 0)
                        {
                            model.minorRevision = groups[8].Value;
                        }

                        if (groups[4] != null && groups[4].Value.Trim().Length > 0)
                        {
                            model.microRevision = groups[4].Value;

                        }
                        else if (groups[9] != null && groups[9].Value.Trim().Length > 0)
                        {
                            model.microRevision = groups[9].Value;
                        }

                        if (groups[5] != null && groups[5].Value.Trim().Length > 0)
                        {
                            model.nanoRevision = groups[5].Value;

                        }
                        else if (groups[10] != null && groups[10].Value.Trim().Length > 0)
                        {
                            model.nanoRevision = groups[10].Value;
                        }
                        return model;

                    }
                }
            }
            return model;
        }
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();
            model.majorRevision = "1";
            model.SetVendor("Microsoft");
            model.SetModel("Windows Phone");
            model.confidence = 40;

            string patternElementsInside = userAgent.GetPatternElementsInside();
            String[] splittedTokens = patternElementsInside.Split(";".ToCharArray());
            foreach (String tokenElement in splittedTokens)
            {
                if (versionRegex.IsMatch(tokenElement))
                {
                    Match versionMatcher = versionRegex.Match(tokenElement);
                    GroupCollection groups = versionMatcher.Groups;

                    if (model.confidence > 40)
                    {
                        model.confidence = 95;

                    }
                    else
                    {
                        model.confidence = 85;
                    }

                    if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                    {
                        model.SetDescription(groups[1].Value);
                    }
                    if (groups[2] != null && groups[2].Value.Trim().Length > 0)
                    {
                        model.majorRevision = groups[2].Value;
                    }
                    if (groups[3] != null && groups[3].Value.Trim().Length > 0)
                    {
                        model.minorRevision = groups[3].Value;
                    }
                    if (groups[4] != null && groups[4].Value.Trim().Length > 0)
                    {
                        model.microRevision = groups[4].Value;
                    }
                }

                if (versionMsieRegex.IsMatch(tokenElement))
                {
                    Match versionMsieMatcher = versionMsieRegex.Match(tokenElement);
                    String version = model.GetVersion();
                    if (version == null || version.Length < 7)
                    {
                        version = "0.0.0.0";
                    }
                    String[] subVersion = version.Split(".".ToCharArray());
                    int count = 0;
                    GroupCollection groups = versionMsieMatcher.Groups;
                    for (int idx = 1; idx <= groups.Count; idx++)
                    {
                        if ((idx >= 1) && (idx <= 4) && groups[idx] != null && groups[idx].Value.Trim().Length > 0)
                        {
                            subVersion[idx - 1] = groups[idx].Value;
                            count++;
                        }
                    }
                    model.SetVersion(subVersion[0] + "." + subVersion[1] + "." + subVersion[2] + "." + subVersion[3]);

                    if (model.confidence > 40)
                    {
                        model.confidence = 95;

                    }
                    else
                    {
                        model.confidence = (count * 18);
                    }
                }
            }
            SetWinCeVersion(model);
            return model;
        }