Ejemplo n.º 1
0
        public static bool TryParse(string value, out SessionToken sessionToken)
        {
            bool result;

            if (!string.IsNullOrWhiteSpace(value))
            {
                try
                {
                    var parts = value.Split(new[] { Colon }, 9);
                    if (parts.Length == 9 && parts[0] == Prefix)
                    {
                        sessionToken = new SessionToken
                                           {
                                               SiteId = parts[1] == "null" ? null : parts[1],
                                               CultureCode = parts[2] == "null" ? null : parts[2],
                                               LanguageCode = parts[3] == "null" ? null : parts[3],
                                               CountryCode = parts[4] == "null" ? null : parts[4],
                                               CurrencyCode = parts[5] == "null" ? null : parts[5],
                                               ExternalId = parts[6] == "null" ? null : parts[6],
                                               SessionId = parts[7] == "null" ? null : parts[7],
                                               PreSessionId = parts[8] == "null" ? null : parts[8]
                                           };
                        result = true;
                    }
                    else
                    {
                        sessionToken = null;
                        result = false;
                    }
                }
                catch (Exception)
                {
                    sessionToken = null;
                    result = false;
                }
            }
            else
            {
                sessionToken = null;
                result = false;
            }


            return result;
        }