/[EmuXPortal]/branches/mono/EmuXPortal.Api/Api/PlatformParser.cs
ViewVC logotype

Diff of /branches/mono/EmuXPortal.Api/Api/PlatformParser.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- branches/mono/EmuXPortal.Api/Api/PlatformParser.cs	2019/05/06 02:26:16	395
+++ branches/mono/EmuXPortal.Api/Api/PlatformParser.cs	2019/06/23 23:32:26	396
@@ -33,7 +33,7 @@
         }
 
         public bool HasExternalConfigs { get { return false; } }
-        public List<IEmuConfig> ExternalConfigs { get { return new List<IEmuConfig>(); } }
+        public HashSet<IEmuConfig> ExternalConfigs { get { return new HashSet<IEmuConfig>(); } }
 
 
         public string GameTitle { get { return ""; } }
@@ -61,33 +61,36 @@
 		{
 			this.cache = cache;
 			if (Directory.Exists (rompath)) {
-				List<string> romdirs = GetRomDirectories (rompath);
+				HashSet<string> romdirs = GetRomDirectories (rompath);
 				gLog.Info.WriteLine ("Found {0} EMU Folders", romdirs.Count);
-				this.Platforms = new List<IEmuConfig> ();
+				this.Platforms = new HashSet<IEmuConfig> ();
 				this.Platforms.Add (new FavoritePlatform ());
 				var emu_platforms = GetEMUConfigFiles (romdirs);
-				this.Platforms.AddRange (emu_platforms);
-				this.Platforms.Sort ();
+				foreach (var c in emu_platforms) {
+					this.Platforms.Add (c);
+				}
 			} else {
-				this.Platforms = new List<IEmuConfig> ();
-				List<IEmuConfig> emu_platforms = new List<IEmuConfig>();
+				this.Platforms = new HashSet<IEmuConfig> ();
+				HashSet<IEmuConfig> emu_platforms = new HashSet<IEmuConfig>();
 				var cached_platforms = cache.GetCachedPlatforms ();
 				this.Platforms.Add (new FavoritePlatform ());
 				foreach (var cached_platform in cached_platforms) {
 					// load the platform from cache
 					emu_platforms.Add(cache.GetCachedPlatformAsEmuConfig(cached_platform.PlatformPath));
 				}
-				this.Platforms.AddRange (emu_platforms);
-				this.Platforms.Sort ();
+				foreach (var c in emu_platforms) {
+					this.Platforms.Add (c);
+				}
 			}
+		this.Platforms = new HashSet<IEmuConfig> (this.Platforms.OrderBy (s => s.PlatformNameLong));
         }
 
-        public List<IEmuConfig> Platforms { get; private set; }
+        public HashSet<IEmuConfig> Platforms { get; private set; }
 
-        private List<string> GetRomDirectories(string path)
+        private HashSet<string> GetRomDirectories(string path)
         {			
 			//gLog.Info.WriteLine("Searching for EMU Folders in: {0}", OSInfo.FormatPath (path));
-            List<string> dirs = new List<string>();
+            HashSet<string> dirs = new HashSet<string>();
 			foreach (string dir in Directory.GetDirectories(OSInfo.FormatPath (path)))
             {
 				DirectoryInfo di = null;
@@ -120,9 +123,9 @@
             return dirs;
         }
 
-        private List<IEmuConfig> GetEMUConfigFiles (List<string> romdirs)
+        private HashSet<IEmuConfig> GetEMUConfigFiles (HashSet<string> romdirs)
 		{
-			List<IEmuConfig> emuconfigs = new List<IEmuConfig> ();
+			HashSet<IEmuConfig> emuconfigs = new HashSet<IEmuConfig> ();
 			//gLog.Info.WriteLine("Reading EMU Config files");
 			int total_count = romdirs.Count;
 			int count = 0;
@@ -146,7 +149,8 @@
 
         public override void Dispose()
         {
-            Platforms.ForEach(x => x.Dispose());
+	/* FIXME: HASHSET FOREACH */
+            //Platforms.ForEach(x => x.Dispose());
             Platforms.Clear();
             Platforms = null;
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22