singrdk/base/Windows/AppReader/XmlManifestParser.cs

60 lines
1.6 KiB
C#
Raw Permalink Normal View History

2008-11-17 18:29:00 -05:00
// ----------------------------------------------------------------------------
2008-03-05 09:52:00 -05:00
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
2008-11-17 18:29:00 -05:00
// ----------------------------------------------------------------------------
2008-03-05 09:52:00 -05:00
namespace ManifestReader
{
using System;
using System.IO;
using System.Collections;
using System.Xml;
using System.Diagnostics;
public abstract class XmlManifestParser : ManifestParser
{
public override Hashtable Parse(string appName, string wxsFile, Hashtable wxElementTranslator)
{
Hashtable outTable = new Hashtable();
StreamReader ios;
2008-11-17 18:29:00 -05:00
try {
2008-03-05 09:52:00 -05:00
ios = new StreamReader(wxsFile);
}
2008-11-17 18:29:00 -05:00
catch (System.IO.FileNotFoundException) {
2008-03-05 09:52:00 -05:00
return outTable;
}
XmlTextReader xmld = new XmlTextReader(ios);
2008-11-17 18:29:00 -05:00
while (xmld.Read())
2008-03-05 09:52:00 -05:00
{
string name = xmld.LocalName;
XmlNodeType xnt = xmld.NodeType;
//Console.WriteLine("Read a line with " + name);
if (xnt == XmlNodeType.Element)
{
//Console.WriteLine("Reading name " + name + " from XML");
string path = Classify(appName, wxsFile, xmld, wxElementTranslator);
// if (path != null)
// "some more ***" + path + "***");
if (path != null)
{
if (outTable.ContainsKey(path))
{
outTable[path] = (int)outTable[path] + 1;
}
2008-11-17 18:29:00 -05:00
else {
2008-03-05 09:52:00 -05:00
outTable[path] = 1;
}
}
}
}
return outTable;
}
public abstract string Classify(string appName, string filename, XmlTextReader xmld, Hashtable wxElementTranslator);
}
}