Inheritance: IEnumerable
Ejemplo n.º 1
0
 public Device(Discoverer discoverer, int index)
 {
     this.discoverer = discoverer;
     this.index = index;
 }
Ejemplo n.º 2
0
    public static void Main(string [] args)
    {
        if(args[0] == "--hal-fdi-dump") {
            HalFdiDump();
            return;
        }

        Discoverer discoverer = new Discoverer();
        //Global.Debug = Global.DebugFlags.ALL;

        foreach(Device device in discoverer) {
            try {
                device.Open();
            } catch(ApplicationException) {
               device.ForeachError(delegate(string error) {
                    Console.WriteLine(error);
                });

                continue;
            }

            device.Capture();

            Console.WriteLine(device);

            if(args.Length == 0) {
                foreach(Song song in device.GetSongs()) {
                    Console.WriteLine(song);
                }
            } else {
                bool get_all = args[0] == "all";

                foreach(string sid in args) {
                    int id =0;

                    if(!get_all) {
                        try {
                            id = Convert.ToInt32(sid);
                        } catch(Exception) {
                            continue;
                        }
                    }

                    foreach(Song song in device.GetSongs()) {
                        if(song.Id != id && !get_all) {
                            continue;
                        }

                        string filename = song.TrackNumber.ToString("00") + ". " + song.Artist
                            + " - " + song.Title + "." + song.Codec.ToLower();

                        device.ProgressChanged += OnProgress;
                        device.ReadSong(song, filename);
                        device.ProgressChanged -= OnProgress;

                        Console.WriteLine("");
                    }
                }
            }

            device.Release();
            device.Dispose();
        }
    }