public static OperateSystem ParseOperateSystem(string userAgent)
 {
     var ret = new OperateSystem { Name = "Unknown", Version = "Unknown" };
     if (userAgent.IndexOf("Windows") >= 0)
     {
         ret.Name = "Windows";
         if (userAgent.IndexOf("Windows 98") >= 0)
             ret.Version = "98";
         else if (userAgent.IndexOf("Windows ME") >= 0)
             ret.Version = "Me";
         else if (userAgent.IndexOf("Windows NT 5.0") >= 0)
             ret.Version = "2000";
         else if (userAgent.IndexOf("Windows NT 5.1") >= 0)
             ret.Version = "XP";
         else if (userAgent.IndexOf("Windows NT 5.2") >= 0)
             ret.Version = "2003";
         else if (userAgent.IndexOf("Windows NT 6.0") >= 0)
             ret.Version = "Vista";
         else if (userAgent.IndexOf("Windows NT 6.1") >= 0)
             ret.Version = "7";
         else if (userAgent.IndexOf("Windows NT 6.2") >= 0)
             ret.Version = "8";
         else if (userAgent.IndexOf("Windows NT 6.3") >= 0)
             ret.Version = "8.1";
         else if (userAgent.IndexOf("Windows NT 6.4") >= 0)
             ret.Version = "10 Preview";
         else if (userAgent.IndexOf("Windows NT 10.0") >= 0)
             ret.Version = "10";
         else if (userAgent.IndexOf("Windows NT 10.1") >= 0)
             ret.Version = "10.1";
         else
             ret.Version = "Unknown";
         return ret;
     }
     else if (userAgent.IndexOf("Mac OS X") >= 0)
     {
         ret.Name = "Mac OS X";
         var begin = userAgent.IndexOf("Mac OS X") + 9;
         var end = userAgent.IndexOf(";", begin);
         ret.Version = userAgent.Substring(begin, end - begin);
         return ret;
     }
     else if (userAgent.IndexOf("Linux") >= 0)
     {
         if (userAgent.IndexOf("Ubuntu") >= 0)
         {
             var begin = userAgent.IndexOf("Ubuntu");
             var end = userAgent.IndexOf(" ", begin);
             if (end < begin) end = userAgent.Length;
             ret.Version = userAgent.Substring(begin, end - begin);
             return ret;
         }
         ret.Name = "Linux";
         ret.Version = "Unknown";
         return ret;
     }
     return ret;
 }
        public static OperateSystem ParseOperateSystem(string userAgent)
        {
            var ret = new OperateSystem {
                Name = "Unknown", Version = "Unknown"
            };

            if (userAgent.IndexOf("Windows") >= 0)
            {
                ret.Name = "Windows";
                if (userAgent.IndexOf("Windows 98") >= 0)
                {
                    ret.Version = "98";
                }
                else if (userAgent.IndexOf("Windows ME") >= 0)
                {
                    ret.Version = "Me";
                }
                else if (userAgent.IndexOf("Windows NT 5.0") >= 0)
                {
                    ret.Version = "2000";
                }
                else if (userAgent.IndexOf("Windows NT 5.1") >= 0)
                {
                    ret.Version = "XP";
                }
                else if (userAgent.IndexOf("Windows NT 5.2") >= 0)
                {
                    ret.Version = "2003";
                }
                else if (userAgent.IndexOf("Windows NT 6.0") >= 0)
                {
                    ret.Version = "Vista";
                }
                else if (userAgent.IndexOf("Windows NT 6.1") >= 0)
                {
                    ret.Version = "7";
                }
                else if (userAgent.IndexOf("Windows NT 6.2") >= 0)
                {
                    ret.Version = "8";
                }
                else if (userAgent.IndexOf("Windows NT 6.3") >= 0)
                {
                    ret.Version = "8.1";
                }
                else if (userAgent.IndexOf("Windows NT 6.4") >= 0)
                {
                    ret.Version = "10 Preview";
                }
                else if (userAgent.IndexOf("Windows NT 10.0") >= 0)
                {
                    ret.Version = "10";
                }
                else if (userAgent.IndexOf("Windows NT 10.1") >= 0)
                {
                    ret.Version = "10.1";
                }
                else
                {
                    ret.Version = "Unknown";
                }
                return(ret);
            }
            else if (userAgent.IndexOf("Mac OS X") >= 0)
            {
                ret.Name = "Mac OS X";
                var begin = userAgent.IndexOf("Mac OS X") + 9;
                var end   = userAgent.IndexOf(";", begin);
                ret.Version = userAgent.Substring(begin, end - begin);
                return(ret);
            }
            else if (userAgent.IndexOf("Linux") >= 0)
            {
                if (userAgent.IndexOf("Ubuntu") >= 0)
                {
                    var begin = userAgent.IndexOf("Ubuntu");
                    var end   = userAgent.IndexOf(" ", begin);
                    if (end < begin)
                    {
                        end = userAgent.Length;
                    }
                    ret.Version = userAgent.Substring(begin, end - begin);
                    return(ret);
                }
                ret.Name    = "Linux";
                ret.Version = "Unknown";
                return(ret);
            }
            return(ret);
        }