Guest User

Untitled

a guest
Mar 20th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Xml.Serialization;
  7. using MameList;
  8.  
  9. //namespace XmlTests {
  10. public class Program {
  11.  
  12.     static void Main(string[] args) {
  13.         // Instantiate the filterer and it will load & parse the supplied file.
  14.         MameListFilterer filterer = new MameListFilterer("list.xml");
  15.  
  16.         CabinetDefinition cab = new CabinetDefinition(); // Define the cabinet.  Don't mention things you don't want to filter on.
  17.         cab.monitor0 = new Monitor {
  18.             type = Monitor.MonitorType.Raster
  19.         };
  20.  
  21.         cab.input = new Input();
  22.         cab.input.buttonsPerPlayer = 8;
  23.  
  24.         cab.input.controls = new List<ControlMethod>();
  25.         cab.input.controls.Add(new ControlMethod {
  26.             type = ControlMethod.ControlType.joy,
  27.         });
  28.  
  29.         filterer.FilterCompatibleGamesByCabinet(cab);  // filter by cabinet definition (optional)
  30.  
  31.         FilterPreferences prefs = new FilterPreferences { // here we can specify other restrictions not related to the cabinet
  32.             Manufacturer = "Nintendo", // partial names work.
  33.             //Status = "imperfect", // imperfect or better.
  34.             //SoldOnOrAfterYear = 1980,
  35.             //SoldOnOrBeforeYear = 2000,
  36.             //RomOf = "neogeo",
  37.             //Description = "NGM" // partial text works
  38.         };
  39.  
  40.         filterer.FilterGamesByPreferences(prefs); // filter by defined preferences. (optional)
  41.  
  42.         var resultGameList = filterer.GetGames(); // get the list of filtered games.
  43.        
  44.         // display the list.
  45.         foreach (var game in resultGameList) {
  46.             Console.WriteLine(game.name + ": " + game.description);
  47.         }
  48.  
  49.         Console.WriteLine(resultGameList.Count() + " Matches.");
  50.  
  51.         // alternately, you can print out XML which matches MAME's own XML format.  This would
  52.         // be suitable for front-ends which can read this type of file.
  53.  
  54.         //XmlSerializer serializer = new XmlSerializer(typeof(mame));
  55.  
  56.         //// describe the structure we're serializing to:
  57.         //mame mameSet = new mame();
  58.         //mameSet.game = resultGameList.ToArray<mameGame>();
  59.  
  60.         //// serialize it into a StringBuilder.
  61.         //StringBuilder output = new StringBuilder();
  62.         //serializer.Serialize(new StringWriter(output), mameSet);
  63.  
  64.         //// print the XML to the console.
  65.         //Console.WriteLine(output.ToString());
  66.     }
  67. }
  68. //}
Advertisement
Add Comment
Please, Sign In to add comment