Created
July 13, 2012 10:47
-
-
Save nelopauselli/3104211 to your computer and use it in GitHub Desktop.
Clase responsable de la lectura de archivos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class MyFileReader | |
{ | |
public void ReadFile(string fileName, Action<string, string, string, string> callback) | |
{ | |
using (var fs = new FileStream(fileName, FileMode.Open)) | |
{ | |
var reader = XmlReader.Create(fs); | |
while (reader.Read()) | |
{ | |
if (reader.Name != "product") continue; | |
var id = reader.GetAttribute("id"); | |
var name = reader.GetAttribute("name"); | |
var unitPrice = reader.GetAttribute("unitPrice"); | |
var discontinued = reader.GetAttribute("discontinued"); | |
callback(id, name, unitPrice, discontinued); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment