in diagutil/Intercounters/XmlTranslator.cs [57:123]
public void Translate(XmlDocument pssdiagDoc)
{
XPathNavigator nav = pssdiagDoc.CreateNavigator();
XPathExpression perfmonObject = nav.Compile("/dsConfig/Collection/Machines/Machine/MachineCollectors/PerfmonCollector/PerfmonCounters/PerfmonObject");
XPathNodeIterator iteratorPerfObject = nav.Select(perfmonObject);
//iterate over PerfmonObjects
while (iteratorPerfObject.MoveNext())
{
string attribute = iteratorPerfObject.Current.GetAttribute("name", "").Substring(1);
string sufix = string.Empty;
int startofsufix = attribute.IndexOf('(');
if (startofsufix >= 0)
{
sufix = attribute.Substring(startofsufix);
attribute = attribute.Substring(0, startofsufix);
}
string substitute = string.Empty;
if (m_dictionary.ContainsKey(attribute))
{
substitute = string.Format("\\{0}{1}", m_dictionary[attribute], sufix);
}
if (string.IsNullOrEmpty(substitute))
{
substitute = string.Format("\\{0}{1}", attribute, sufix);
}
//delete english PerfmonObjects name and add local PerfmonObjects name
XPathNavigator currentNode = iteratorPerfObject.Current;
currentNode.MoveToAttribute("name", "");
currentNode.DeleteSelf();
iteratorPerfObject.Current.CreateAttribute("", "name", "", substitute);
//iterate throught PerfmonCounter searching for matches
XPathExpression perfmonCounter = iteratorPerfObject.Current.Compile("PerfmonCounter");
XPathNodeIterator iteratorPerfCounter = iteratorPerfObject.Current.Select(perfmonCounter);
while (iteratorPerfCounter.MoveNext())
{
string attributePerfCounter = iteratorPerfCounter.Current.GetAttribute("name", "").Substring(1);
string substitutePerfCounter = string.Empty;
string sufixPerfCounter = string.Empty;
int startofsufixPerfCounter = attributePerfCounter.IndexOf('(');
if (startofsufixPerfCounter >= 0)
{
sufixPerfCounter = attributePerfCounter.Substring(startofsufixPerfCounter);
attributePerfCounter = attributePerfCounter.Substring(0, startofsufixPerfCounter);
}
if (m_dictionary.ContainsKey(attributePerfCounter))
{
substitutePerfCounter = string.Format("\\{0}{1}", m_dictionary[attributePerfCounter], sufixPerfCounter);
}
if (string.IsNullOrEmpty(substitutePerfCounter))
{
substitutePerfCounter = string.Format("\\{0}{1}", attributePerfCounter, sufixPerfCounter);
}
//delete english PerfmonCounter name and add local PerfmonCounter name
XPathNavigator currentNodePerfCounter = iteratorPerfCounter.Current;
currentNodePerfCounter.MoveToAttribute("name", "");
currentNodePerfCounter.DeleteSelf();
iteratorPerfCounter.Current.CreateAttribute("", "name", "", substitutePerfCounter);
}
}
}