Exemplo n.º 1
0
        static void LoadFile(string filename)
        {
            if (!File.Exists(filename))
            {
                return;
            }

            TextReader input = new StreamReader(File.OpenRead(filename));

            using (input) {
                string    str;
                Hashtable allhash     = new Hashtable(StringComparer.OrdinalIgnoreCase);
                int       aux         = 0;
                ArrayList browserData = new ArrayList();
                while ((str = input.ReadLine()) != null)
                {
                    if (str.Length == 0 || str [0] == ';')
                    {
                        continue;
                    }

                    string      userAgent = str.Substring(1, str.Length - 2);
                    BrowserData data      = new BrowserData(userAgent);
                    ReadCapabilities(input, data);

                    /* Ignore default browser and file version information */
                    if (userAgent == "*" || userAgent == "GJK_Browscap_Version")
                    {
                        continue;
                    }

                    string key = data.GetBrowser();
                    if (key == null || allhash.ContainsKey(key))
                    {
                        allhash.Add(aux++, data);
                        browserData.Add(data);
                    }
                    else
                    {
                        allhash.Add(key, data);
                        browserData.Add(data);
                    }
                }

                alldata = browserData;
                foreach (BrowserData data in alldata)
                {
                    string pname = data.GetParentName();
                    if (pname == null)
                    {
                        continue;
                    }

                    data.Parent = (BrowserData)allhash [pname];
                }
            }
        }
Exemplo n.º 2
0
		static void LoadFile (string filename)
		{
			if (!File.Exists (filename))
				return;

			TextReader input = new StreamReader (File.OpenRead (filename));
			using (input) {
			string str;
			Hashtable allhash = new Hashtable (StringComparer.OrdinalIgnoreCase);
			int aux = 0;
			ArrayList browserData = new ArrayList ();
			while ((str = input.ReadLine ()) != null) {
				if (str.Length == 0 || str [0] == ';')
					continue;

				string userAgent = str.Substring (1, str.Length - 2);
				BrowserData data = new BrowserData (userAgent);
				ReadCapabilities (input, data);

				/* Ignore default browser and file version information */
				if (userAgent == "*" || userAgent == "GJK_Browscap_Version")
					continue;

				string key = data.GetBrowser ();
				if (key == null || allhash.ContainsKey (key)) {
					allhash.Add (aux++, data);
					browserData.Add (data);
				} else {
					allhash.Add (key, data);
					browserData.Add (data);
				}
			}			

			alldata = browserData;
			foreach (BrowserData data in alldata) {
				string pname = data.GetParentName ();
				if (pname == null)
					continue;

				data.Parent = (BrowserData) allhash [pname];
			}
			}
		}
		static void LoadFile (string filename)
		{
#if TARGET_J2EE
			TextReader input = GetJavaTextReader(filename);
			if(input == null)
				return;
#else
			if (!File.Exists (filename))
				return;

			TextReader input = new StreamReader (File.OpenRead (filename));
#endif
			string str;
			Hashtable allhash = new Hashtable ();
			int aux = 0;
			while ((str = input.ReadLine ()) != null) {
				if (str.Length == 0 || str [0] == ';')
					continue;

				string userAgent = str.Substring (1, str.Length - 2);
				BrowserData data = new BrowserData (userAgent);
				ReadCapabilities (input, data);

				/* Ignore default browser and file version information */
				if (userAgent == "*" || userAgent == "GJK_Browscap_Version")
					continue;

				string key = data.GetBrowser ();
				if (key == null || allhash.ContainsKey (key)) {
					allhash.Add (aux++, data);
				} else {
					allhash.Add (key, data);
				}
			}

			alldata = allhash.Values;
			foreach (BrowserData data in alldata) {
				if (data.Parent != null)
					continue;

				string pname = data.GetParentName ();
				if (pname != null)
					data.Parent = (BrowserData) allhash [pname];
			}
		}