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; }