本文整理汇总了C#中Preferences.node方法的典型用法代码示例。如果您正苦于以下问题:C# Preferences.node方法的具体用法?C# Preferences.node怎么用?C# Preferences.node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences.node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadNode
private static void loadNode(Preferences prefs, org.w3c.dom.Element node)
{
//throws TransformerException {
// load preferences
org.w3c.dom.NodeList children = org.apache.xpath.XPathAPI.selectNodeList (node, "node"); //$NON-NLS-1$
org.w3c.dom.NodeList entries = org.apache.xpath.XPathAPI.selectNodeList (node, "map/entry"); //$NON-NLS-1$
int childNumber = children.getLength ();
Preferences[] prefChildren = new Preferences[childNumber];
int entryNumber = entries.getLength ();
lock (((AbstractPreferences) prefs).lockJ) {
if (((AbstractPreferences)prefs).isRemoved ()) {
return;
}
for (int i = 0; i < entryNumber; i++) {
org.w3c.dom.Element entry = (org.w3c.dom.Element)entries.item (i);
String key = entry.getAttribute ("key"); //$NON-NLS-1$
String value = entry.getAttribute ("value"); //$NON-NLS-1$
prefs.put (key, value);
}
// get children preferences node
for (int i = 0; i < childNumber; i++) {
org.w3c.dom.Element child = (org.w3c.dom.Element)children.item (i);
String name = child.getAttribute ("name"); //$NON-NLS-1$
prefChildren [i] = prefs.node (name);
}
}
// load children nodes after unlock
for (int i = 0; i < childNumber; i++) {
loadNode (prefChildren [i], (org.w3c.dom.Element)children.item (i));
}
}
示例2: exportSubTree
private static void exportSubTree(Preferences prefs, java.io.BufferedWriter outJ)
{
//throws BackingStoreException, IOException {
String[] names = prefs.childrenNames ();
if (names.Length > 0) {
for (int i = 0; i < names.Length; i++) {
Preferences child = prefs.node (names [i]);
flushStartTag (
"node", new String[] { "name" }, new String[] { names [i] }, outJ); //$NON-NLS-1$ //$NON-NLS-2$
exportEntries (child, outJ);
exportSubTree (child, outJ);
flushEndTag ("node", outJ); //$NON-NLS-1$
}
}
}