SetDescription() public method

public SetDescription ( String description ) : void
description String
return void
コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        public BuiltObject Build(UserAgent userAgent, int confidenceTreshold)
        {
            OSModel.OperatingSystem model = new OSModel.OperatingSystem();
            model.majorRevision = "1";
            model.SetVendor("Google");
            model.SetModel("Android");
            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 = 100;

                    }
                    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 (groups[6] != null && groups[6].Value.Trim().Length > 0)
                    {
                        model.SetDescription(groups[6].Value);
                    }
                }

                if (buildHashRegex.IsMatch(tokenElement))
                {
                    Match buildHashMatcher = buildHashRegex.Match(tokenElement);
                    GroupCollection groups = buildHashMatcher.Groups;

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

                    }
                    else
                    {
                        model.confidence = 45;
                    }

                    if (groups[1] != null && groups[1].Value.Trim().Length > 0)
                    {
                        model.SetBuild(groups[1].Value);
                    }
                }
            }
            return model;
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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;
        }