Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Xml.Serialization;
- using MameList;
- //namespace XmlTests {
- public class Program {
- static void Main(string[] args) {
- // Instantiate the filterer and it will load & parse the supplied file.
- MameListFilterer filterer = new MameListFilterer("list.xml");
- CabinetDefinition cab = new CabinetDefinition(); // Define the cabinet. Don't mention things you don't want to filter on.
- cab.monitor0 = new Monitor {
- type = Monitor.MonitorType.Raster
- };
- cab.input = new Input();
- cab.input.buttonsPerPlayer = 8;
- cab.input.controls = new List<ControlMethod>();
- cab.input.controls.Add(new ControlMethod {
- type = ControlMethod.ControlType.joy,
- });
- filterer.FilterCompatibleGamesByCabinet(cab); // filter by cabinet definition (optional)
- FilterPreferences prefs = new FilterPreferences { // here we can specify other restrictions not related to the cabinet
- Manufacturer = "Nintendo", // partial names work.
- //Status = "imperfect", // imperfect or better.
- //SoldOnOrAfterYear = 1980,
- //SoldOnOrBeforeYear = 2000,
- //RomOf = "neogeo",
- //Description = "NGM" // partial text works
- };
- filterer.FilterGamesByPreferences(prefs); // filter by defined preferences. (optional)
- var resultGameList = filterer.GetGames(); // get the list of filtered games.
- // display the list.
- foreach (var game in resultGameList) {
- Console.WriteLine(game.name + ": " + game.description);
- }
- Console.WriteLine(resultGameList.Count() + " Matches.");
- // alternately, you can print out XML which matches MAME's own XML format. This would
- // be suitable for front-ends which can read this type of file.
- //XmlSerializer serializer = new XmlSerializer(typeof(mame));
- //// describe the structure we're serializing to:
- //mame mameSet = new mame();
- //mameSet.game = resultGameList.ToArray<mameGame>();
- //// serialize it into a StringBuilder.
- //StringBuilder output = new StringBuilder();
- //serializer.Serialize(new StringWriter(output), mameSet);
- //// print the XML to the console.
- //Console.WriteLine(output.ToString());
- }
- }
- //}
Advertisement
Add Comment
Please, Sign In to add comment