GetPatternElementsPre() public method

public GetPatternElementsPre ( ) : String
return String
        private Device ElaborateWinPhoneDeviceWithToken(UserAgent userAgent, String token)
        {
            if (userAgent.mozillaPattern || userAgent.operaPattern)
            {
                int subtract = 0;
                String currentToken = token;

                String looseToken = (String)(regexs[token + "_loose"]);
                //String looseToken = Regex.Replace(token, "[ _/-]", ".?");

                Regex looseRegex = (Regex)(regexs[token + "_loose_icase_regex"]);
                //Regex looseRegex = new Regex(/*"(?i).*"*/".*" + looseToken + ".*", RegexOptions.IgnoreCase);

                if (!looseRegex.IsMatch(userAgent.completeUserAgent))
                {
                    return null;
                }

                Regex currentRegex = null;

                if (userAgent.operaPattern)
                {
                    subtract += 10;
                }

                for (int i = 0; i <= 1; i++)
                {
                    if (i == 1)
                    {
                        currentToken = looseToken;
                    }

                    currentRegex = new Regex(/*"(?i).*"*/".?>*" + currentToken, RegexOptions.IgnoreCase);
                    if (userAgent.GetPatternElementsInside() != null && currentRegex.IsMatch(userAgent.GetPatternElementsInside()))
                    {
                        String deviceId = (String)orderedRules[token];

                        Device retDevice = null;
                        if (devices.TryGetValue(deviceId, out retDevice))
                        {
                            retDevice = (Device)retDevice.Clone();
                            retDevice.confidence = (100 - subtract);
                            return retDevice;
                        }
                    }
                    if (userAgent.GetPatternElementsPre() != null && currentRegex.IsMatch(userAgent.GetPatternElementsPre()))
                    {
                        String deviceId = (String)orderedRules[token];

                        Device retDevice = null;
                        if (devices.TryGetValue(deviceId, out retDevice))
                        {
                            retDevice = (Device)retDevice.Clone();
                            retDevice.confidence = (95 - subtract);
                            return retDevice;
                        }
                    }

                    currentRegex = new Regex(/*"(?i).*"*/".?>*" + currentToken + ".?;.*", RegexOptions.IgnoreCase);
                    if (userAgent.GetPatternElementsInside() != null && currentRegex.IsMatch(userAgent.GetPatternElementsInside()))
                    {
                        String deviceId = (String)orderedRules[token];

                        Device retDevice = null;
                        if (devices.TryGetValue(deviceId, out retDevice))
                        {
                            retDevice = (Device)retDevice.Clone();
                            retDevice.confidence = (90 - subtract);
                            return retDevice;
                        }
                    }

                    if (i == 1)
                    {
                        currentRegex = looseRegex;

                    }
                    else
                    {
                        currentRegex = new Regex(/*"(?i).*"*/".?>*" + currentToken + ".*", RegexOptions.IgnoreCase);
                    }

                    if (userAgent.GetPatternElementsInside() != null && currentRegex.IsMatch(userAgent.GetPatternElementsInside()))
                    {
                        String deviceId = (String)orderedRules[token];

                        Device retDevice = null;
                        if (devices.TryGetValue(deviceId, out retDevice))
                        {
                            retDevice = (Device)retDevice.Clone();
                            retDevice.confidence = (80 - subtract);
                            return retDevice;
                        }
                    }
                    if (userAgent.GetPatternElementsPre() != null && currentRegex.IsMatch(userAgent.GetPatternElementsPre()))
                    {
                        String deviceId = (String)orderedRules[token];

                        Device retDevice = null;
                        if (devices.TryGetValue(deviceId, out retDevice))
                        {
                            retDevice = (Device)retDevice.Clone();
                            retDevice.confidence = (80 - subtract);
                            return retDevice;
                        }
                    }
                    if (userAgent.GetPatternElementsPost() != null && currentRegex.IsMatch(userAgent.GetPatternElementsPost()))
                    {
                        String deviceId = (String)orderedRules[token];

                        Device retDevice = null;
                        if (devices.TryGetValue(deviceId, out retDevice))
                        {
                            retDevice = (Device)retDevice.Clone();
                            retDevice.confidence = (60 - subtract);
                            return retDevice;
                        }
                    }
                    subtract += 20;
                }
            }

            return null;
        }
        private Device ElaborateSymbianDeviceWithToken(UserAgent userAgent, String token)
        {
            String originalToken = token;

            if (userAgent.mozillaPattern || userAgent.operaPattern)
            {
                int subtract = 0;
                String currentToken = token;

                String looseToken = (String)(regexs[token + "_loose"]);
                //String looseToken = Regex.Replace(token, "[ _/-]", ".?");

                Regex looseRegex = (Regex)(regexs[token + "_loose_icase_regex"]);
                //Regex looseRegex = new Regex(".*" + looseToken + ".*");

                if (!looseRegex.IsMatch(userAgent.completeUserAgent))
                {
                    return null;
                }

                Regex currentRegex = null;

                if (userAgent.operaPattern)
                {
                    subtract += 10;
                }
                for (int i = 0; i <= 1; i++)
                {
                    if (i == 1)
                    {
                        currentToken = looseToken;
                    }

                    currentRegex = new Regex(".?>*Series60.?(\\d+)\\.(\\d+).?" + currentToken + ".*");
                    if (userAgent.GetPatternElementsInside() != null && currentRegex.IsMatch(userAgent.GetPatternElementsInside()))
                    {
                        if (orderedRules.Contains(originalToken))
                        {
                            String deviceId = (String)orderedRules[originalToken];
                            Device retDevice = null;
                            if (devices.TryGetValue(deviceId, out retDevice))
                            {
                                retDevice = (Device)retDevice.Clone();
                                retDevice.confidence = (100 - subtract);
                                return retDevice;
                            }
                        }
                    }

                    currentRegex = new Regex(".?>*" + currentToken);
                    if (userAgent.GetPatternElementsPre() != null && currentRegex.IsMatch(userAgent.GetPatternElementsPre()))
                    {
                        if (orderedRules.Contains(originalToken))
                        {
                            String deviceId = (String)orderedRules[originalToken];
                            Device retDevice = null;
                            if (devices.TryGetValue(deviceId, out retDevice))
                            {
                                retDevice = (Device)retDevice.Clone();
                                retDevice.confidence = (95 - subtract);
                                return retDevice;
                            }
                        }
                    }

                    if (userAgent.GetPatternElementsInside() != null && currentRegex.IsMatch(userAgent.GetPatternElementsInside()))
                    {
                        if (orderedRules.Contains(originalToken))
                        {
                            String deviceId = (String)orderedRules[originalToken];
                            Device retDevice = null;
                            if (devices.TryGetValue(deviceId, out retDevice))
                            {
                                retDevice = (Device)retDevice.Clone();
                                retDevice.confidence = (90 - subtract);
                                return retDevice;
                            }
                        }
                    }

                    currentRegex = new Regex(".?>*" + currentToken + ".?;.*");
                    if (userAgent.GetPatternElementsInside() != null && currentRegex.IsMatch(userAgent.GetPatternElementsInside()))
                    {
                        if (orderedRules.Contains(originalToken))
                        {
                            String deviceId = (String)orderedRules[originalToken];
                            Device retDevice = null;
                            if (devices.TryGetValue(deviceId, out retDevice))
                            {
                                retDevice = (Device)retDevice.Clone();
                                retDevice.confidence = (90 - subtract);
                                return retDevice;
                            }
                        }
                    }

                    if (i == 1)
                    {
                        currentRegex = looseRegex;

                    }
                    else
                    {
                        currentRegex = new Regex(".?>*" + currentToken + ".*");
                    }

                    if (userAgent.GetPatternElementsInside() != null && currentRegex.IsMatch(userAgent.GetPatternElementsInside()))
                    {
                        if (orderedRules.Contains(originalToken))
                        {
                            String deviceId = (String)orderedRules[originalToken];
                            Device retDevice = null;
                            if (devices.TryGetValue(deviceId, out retDevice))
                            {
                                retDevice = (Device)retDevice.Clone();
                                retDevice.confidence = (80 - subtract);
                                return retDevice;
                            }
                        }
                    }

                    if (userAgent.GetPatternElementsPre() != null && currentRegex.IsMatch(userAgent.GetPatternElementsPre()))
                    {
                        if (orderedRules.Contains(originalToken))
                        {
                            String deviceId = (String)orderedRules[currentToken];
                            Device retDevice = null;
                            if (devices.TryGetValue(deviceId, out retDevice))
                            {
                                retDevice = (Device)retDevice.Clone();
                                retDevice.confidence = (80 - subtract);
                                return retDevice;
                            }
                        }
                    }

                    if (userAgent.GetPatternElementsPost() != null && currentRegex.IsMatch(userAgent.GetPatternElementsPost()))
                    {
                        if (orderedRules.Contains(originalToken))
                        {
                            String deviceId = (String)orderedRules[currentToken];
                            Device retDevice = null;
                            if (devices.TryGetValue(deviceId, out retDevice))
                            {
                                retDevice = (Device)retDevice.Clone();
                                retDevice.confidence = (60 - subtract);
                                return retDevice;
                            }
                        }
                    }
                    subtract += 20;
                }
            }
            else
            {
                String ua = Regex.Replace(userAgent.completeUserAgent, "SN[0-9]*", "");

                int subtract = 0;
                String currentToken = token;

                String looseToken = (String)(regexs[token + "_loose"]);
                //String looseToken = Regex.Replace(token, "[ _/-]", ".?");

                Regex looseRegex = (Regex)(regexs[token + "_loose_icase_regex"]);
                //Regex looseRegex = new Regex(".*" + looseToken + ".*");

                if (!looseRegex.IsMatch(userAgent.completeUserAgent))
                {
                    return null;
                }

                Regex currentRegex = null;

                for (int i = 0; i <= 1; i++)
                {
                    if (i == 1)
                    {
                        currentToken = looseToken;
                    }

                    currentRegex = new Regex(".?>*" + currentToken + ".*");
                    if (currentRegex.IsMatch(ua))
                    {
                        if (orderedRules.Contains(originalToken))
                        {
                            string deviceId = orderedRules[originalToken] as string;

                            if (devices.ContainsKey(deviceId))
                            {
                                Device retDevice = (Device)devices[deviceId].Clone();
                                retDevice.confidence = 100 - subtract;
                                return retDevice;
                            }
                        }
                    }

                    subtract += 20;
                }
            }

            return null;
        }