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

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

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

--- branches/mono/EmuXPortal.Api/Api/RomParser.cs	2019/05/06 02:26:16	395
+++ branches/mono/EmuXPortal.Api/Api/RomParser.cs	2019/06/23 23:32:26	396
@@ -22,12 +22,12 @@
 			this.Config = config;
 			if (!this.Config.IsFavorites) {
 				gLog.Info.WriteLine ("Getting Roms for platform: {0}", config.PlatformNameShort);
-				List<IRomConfigPair> roms = new List<IRomConfigPair> ();
+				HashSet<IRomConfigPair> roms = new HashSet<IRomConfigPair> ();
 				bool platform_is_cached = cache.isPlatformPathCached (config.PlatformPath);
 				if (platform_is_cached) {
 					var cached_platform = cache.GetCachedPlatform (config.PlatformPath);
 					if (cached_platform.HasExternalConfigs) {
-						List<IExternalEmuConfig> ieecs = cached_platform.ExternalConfigs;
+						HashSet<IExternalEmuConfig> ieecs = cached_platform.ExternalConfigs;
 						foreach (IExternalEmuConfig ieec in ieecs) {
 							IEmuConfig iec = new EmuConfigLoader.EmuConfig (ieec);
 							iec.EmuRomPath = cached_platform.EmulatorRomPath;
@@ -35,7 +35,7 @@
 							roms.Add (new RomConfigPair (reconfig.GameExe, reconfig.GameImage, reconfig));
 						}
 					} else {
-						List<IEmuRom> iers = cached_platform.Roms;
+						HashSet<IEmuRom> iers = cached_platform.Roms;
 						foreach (var ier in iers) {
 							roms.Add (new RomConfigPair (ier.RomFile, ier.RomImage, Config));
 						}
@@ -49,7 +49,7 @@
 					// don't need to generate any rom config if the platform was cached
 					this.Roms = GenerateRomConfig (roms, config);
 				} else {
-					List<IRomConfig> romconfigs = new List<IRomConfig> ();
+					HashSet<IRomConfig> romconfigs = new HashSet<IRomConfig> ();
 					foreach (IRomConfigPair rom in roms) {						
 						RomLoader.RomConfig crom = new RomLoader.RomConfig (rom.RomFile, rom.RomImage, rom.RomConfig);
 						romconfigs.Add (crom);						
@@ -62,21 +62,21 @@
 				gLog.Info.WriteLine ("Found {0} Roms", this.Roms.Count);
 			}
 		}
-		public List<IRomConfig> Roms { get; private set; }
-		private List<IRomConfigPair> GetRoms ()
+		public HashSet<IRomConfig> Roms { get; private set; }
+		private HashSet<IRomConfigPair> GetRoms ()
 		{
 			if (Config.HasExternalConfigs) { return GetRomsEX (); }
 			string path = Config.EmuRomPath; string searchPattern = Config.Extenstions;
 			gLog.Info.WriteLine ("Searching for Roms in Folder: {0}", path);
 			Predicate<string> rom_predicate = new Predicate<string> (delegate (string t) {
 				string search_exts = searchPattern.Replace ("*", "");
-				List<string> exts = new List<string> (search_exts.Split (new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries));
+				HashSet<string> exts = new HashSet<string> (search_exts.Split (new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries));
 				string ext = Path.GetExtension (t).ToLower ();
 				return exts.Contains (ext) && t.ToLower ().EndsWith (ext);
 			});
-			List<string> roms = (searchPattern == "*.*")
-			    ? new List<string> (Directory.GetFiles (path, "*.*", SearchOption.AllDirectories))
-			    : new List<string> (Directory.GetFiles (path, "*.*", SearchOption.AllDirectories).Where (s => rom_predicate (s)));
+			HashSet<string> roms = (searchPattern == "*.*")
+			    ? new HashSet<string> (Directory.GetFiles (path, "*.*", SearchOption.AllDirectories))
+			    : new HashSet<string> (Directory.GetFiles (path, "*.*", SearchOption.AllDirectories).Where (s => rom_predicate (s)));
 
 			#region LIST_ADDED_ROMS
 #if LIST_ADDED_ROMS
@@ -86,7 +86,7 @@
                 logger.WriteLine("\tAdding: {0}", fi.Name);
             }
 #endif
-			List<IRomConfigPair> rompairlist = new List<IRomConfigPair> ();
+			HashSet<IRomConfigPair> rompairlist = new HashSet<IRomConfigPair> ();
 			foreach (string rom in roms) {
 				/* TODO: 
 				1) Do we leave the image paramter emptry?
@@ -99,10 +99,10 @@
 			return rompairlist;
 		}
 
-		private List<IRomConfigPair> GetRomsEX ()
+		private HashSet<IRomConfigPair> GetRomsEX ()
 		{
-			List<IEmuConfig> configs = Config.ExternalConfigs;
-			List<IRomConfigPair> roms = new List<IRomConfigPair> ();
+			HashSet<IEmuConfig> configs = Config.ExternalConfigs;
+			HashSet<IRomConfigPair> roms = new HashSet<IRomConfigPair> ();
 
 
 			foreach (IEmuConfig config in configs) {
@@ -134,12 +134,12 @@
 			c.ConfigPath = child_config.ConfigPath;
 			return c;
 		}
-		private List<IRomConfig> GenerateRomConfig (List<IRomConfigPair> roms, IEmuConfig config)
+		private HashSet<IRomConfig> GenerateRomConfig (HashSet<IRomConfigPair> roms, IEmuConfig config)
 		{
 			int total_count = roms.Count;
 			int count = 0;
 			int update_modulus = (int)Math.Ceiling (0.01 * (double)total_count);
-			List<IRomConfig> romconfigs = new List<IRomConfig> ();
+			HashSet<IRomConfig> romconfigs = new HashSet<IRomConfig> ();
 			//gLog.Debug.WriteLine("Generating Rom Configs");
 			foreach (IRomConfigPair rom in roms) {
 				IRomConfig crom = RomLoader.Load (rom.RomFile, rom.RomImage, rom.RomConfig);
@@ -184,7 +184,8 @@
 
 		public override void Dispose ()
 		{
-			Roms.ForEach (x => x.Dispose ());
+			/* FIXME: HASHSET FOREACH */
+			//Roms.ForEach (x => x.Dispose ());
 			Roms.Clear ();
 			Roms = null;
 		}

 

  ViewVC Help
Powered by ViewVC 1.1.22