private bool ReadXMLFile(FileInfo fi) { xtr = new XmlTextReader(fi.FullName); if (!CheckIfMimeFileIsCorrect( )) { xtr.Close( ); Console.WriteLine(fi.Name + " doesn't seem to be a correct freedesktop shared mime info file..."); return(false); } Console.WriteLine(fi.Name + " seems to be a correct freedesktop shared mime info file..."); Console.WriteLine("Start parsing..."); while (xtr.Read( )) { switch (xtr.NodeType) { case XmlNodeType.Element: if (xtr.Name == "mime-type") { MimeType mt = new MimeType( ); MimeTypeReader mtr = new MimeTypeReader(xtr, mt); mtr.Start( ); if (!MimeUtils.CheckIfMimetypeExists(mt)) { MimeUtils.mimeTypes.Add(mt); } } break; case XmlNodeType.EndElement: if (xtr.Name == "mime-info") { break; } break; } } xtr.Close( ); return(true); }
private bool ReadXMLFile( FileInfo fi ) { xtr = new XmlTextReader( fi.FullName ); if ( !CheckIfMimeFileIsCorrect( ) ) { xtr.Close( ); Console.WriteLine( fi.Name + " doesn't seem to be a correct freedesktop shared mime info file..." ); return false; } Console.WriteLine( fi.Name + " seems to be a correct freedesktop shared mime info file..." ); Console.WriteLine( "Start parsing..." ); while ( xtr.Read( ) ) { switch ( xtr.NodeType ) { case XmlNodeType.Element: if ( xtr.Name == "mime-type" ) { MimeType mt = new MimeType( ); MimeTypeReader mtr = new MimeTypeReader( xtr, mt ); mtr.Start( ); if ( !MimeUtils.CheckIfMimetypeExists( mt ) ) MimeUtils.mimeTypes.Add( mt ); } break; case XmlNodeType.EndElement: if ( xtr.Name == "mime-info" ) break; break; } } xtr.Close( ); return true; }