本文整理匯總了C#中System.Xml.XPath.XPathNavigator.SelectChildren方法的典型用法代碼示例。如果您正苦於以下問題:C# XPathNavigator.SelectChildren方法的具體用法?C# XPathNavigator.SelectChildren怎麽用?C# XPathNavigator.SelectChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.SelectChildren方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ParseConfiguration
protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
{
//<MinValue>-6</MinValue>
//<MaxValue>42</MaxValue>
foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
{
switch (node.LocalName)
{
case MinValueName:
int minValue;
if (Int32.TryParse(node.InnerXml, out minValue))
_minValue = minValue;
break;
case MaxValueName:
int maxValue;
if (Int32.TryParse(node.InnerXml, out maxValue))
_maxValue = maxValue;
break;
case ShowAsPercentageName:
bool perc;
if (Boolean.TryParse(node.InnerXml, out perc))
_showAsPercentage = perc;
break;
}
}
}
示例2: Deserialize
/// <summary>
/// Creates a notification channel from the XML representation.
/// </summary>
/// <param name="navigator">The navigator to read the information from. </param>
/// <returns>The notification channel.</returns>
///
/// <exception cref="ArgumentNullException">
/// The <paramref name="navigator"/> parameter is <b>null</b>.
/// </exception>
///
/// <exception cref="InvalidOperationException">
/// The notification channel defined in the XML is not recognized.
/// </exception>
public static NotificationChannel Deserialize(XPathNavigator navigator)
{
Validator.ThrowIfNavigatorNull(navigator);
// find out what kind of node we have, and go from there...
NotificationChannel channel = null;
foreach (XPathNavigator typeSpecificNav in navigator.SelectChildren(XPathNodeType.Element))
{
switch (typeSpecificNav.Name)
{
case "http-notification-channel":
channel = new HttpNotificationChannel();
channel.ParseXml(navigator);
break;
default:
throw new InvalidOperationException(
String.Format(
CultureInfo.InvariantCulture,
ResourceRetriever.GetResourceString("UnrecognizedNotificationChannelType"),
typeSpecificNav.Name));
}
}
return channel;
}
示例3: ReadDelegates
private DelegateCollection ReadDelegates(XPathNavigator specs)
{
DelegateCollection delegates = new DelegateCollection();
foreach (XPathNavigator node in specs.SelectChildren("function", String.Empty))
{
var name = node.GetAttribute("name", String.Empty);
// Check whether we are adding to an existing delegate or creating a new one.
Delegate d = null;
if (delegates.ContainsKey(name))
{
d = delegates[name];
}
else
{
d = new Delegate();
d.Name = name;
d.Version = node.GetAttribute("version", String.Empty);
d.Category = node.GetAttribute("category", String.Empty);
d.DeprecatedVersion = node.GetAttribute("deprecated", String.Empty);
d.Deprecated = !String.IsNullOrEmpty(d.DeprecatedVersion);
d.Obsolete = node.GetAttribute("obsolete", String.Empty);
}
foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
{
switch (param.Name)
{
case "returns":
d.ReturnType.CurrentType = param.GetAttribute("type", String.Empty);
break;
case "param":
Parameter p = new Parameter();
p.CurrentType = param.GetAttribute("type", String.Empty);
p.Name = param.GetAttribute("name", String.Empty);
string element_count = param.GetAttribute("elementcount", String.Empty);
if (String.IsNullOrEmpty(element_count))
element_count = param.GetAttribute("count", String.Empty);
if (!String.IsNullOrEmpty(element_count))
p.ElementCount = Int32.Parse(element_count);
p.Flow = Parameter.GetFlowDirection(param.GetAttribute("flow", String.Empty));
d.Parameters.Add(p);
break;
}
}
delegates.Add(d);
}
return delegates;
}
示例4: ParseConfiguration
protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
{
//<ExpectedXmlNamespace>htp://example.com/namespace</ExpectedXmlNamespace>
foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
{
if (element.LocalName != ExpectedXmlNamespaceName)
continue;
_expectedXmlNamespace = element.InnerXml;
return;
}
}
示例5: GetElementValue
private static string GetElementValue(string elementname, XPathNavigator node)
{
XPathNodeIterator element = node.SelectChildren(elementname, "");
if (element.Count > 0)
{
element.MoveNext();
return element.Current.Value;
}
return String.Empty;
}
示例6: ParseTestUnitsReport
/// <summary>
/// Parses child TestUnit nodes.
/// </summary>
/// <param name="nav">The parent XPathNavigator which hosts TestUnit nodes.</param>
/// <param name="parent">The parent TestSuite to which TestUnits are attached to.</param>
/// <param name="collection">The TestResultCollection which will host the result.</param>
private static void ParseTestUnitsReport(XPathNavigator nav, TestSuite parent, TestResultCollection collection)
{
foreach (XPathNavigator child in nav.SelectChildren(Xml.TestSuite, string.Empty))
{
ParseTestSuiteReport(child, parent, collection);
}
foreach (XPathNavigator child in nav.SelectChildren(Xml.TestCase, string.Empty))
{
ParseTestCaseReport(child, parent, collection);
}
}
示例7: ParseConfiguration
protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
{
foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
{
switch(element.LocalName)
{
case IsTextConfigString:
_isText = element.InnerXml == "true";
break;
}
}
}
示例8: Parse
protected virtual void Parse(XPathNavigator navigator)
{
sessionFactoryName = navigator.GetAttribute(CfgXmlHelper.SessionFactoryNameAttribute, "");
XPathNodeIterator xpni = navigator.SelectChildren(CfgXmlHelper.PropertiesNodeName, CfgXmlHelper.CfgSchemaXMLNS);
while (xpni.MoveNext())
{
string propName = xpni.Current.GetAttribute(CfgXmlHelper.PropertyNameAttribute, "");
string propValue = xpni.Current.Value;
if (!string.IsNullOrEmpty(propName) && !string.IsNullOrEmpty(propValue))
properties[propName] = propValue;
}
}
示例9: ParseConfiguration
protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
{
base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);
foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
{
switch (node.LocalName)
{
case UrlFormatName:
ParseEnumValue(node.InnerXml, ref _format);
break;
}
}
}
示例10: ParseConfiguration
protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
{
base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);
foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
{
switch (node.LocalName)
{
case FormatName:
if (!string.IsNullOrEmpty(node.InnerXml))
_format = node.InnerXml;
break;
}
}
}
示例11: ParseConfiguration
protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
{
base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);
//<Regex>^[a-zA-Z0-9]*$</Regex>
foreach (XPathNavigator element in configurationElement.SelectChildren(XPathNodeType.Element))
{
switch (element.LocalName)
{
case RegexName:
_regex = element.InnerXml;
break;
}
}
}
示例12: ParseConfiguration
protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
{
//<MinValue>-6</MinValue>
//<MaxValue>42</MaxValue>
foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
{
switch (node.LocalName)
{
case EvenOnlyName:
bool evenOnlyValue;
if (Boolean.TryParse(node.InnerXml, out evenOnlyValue))
_evenOnly = evenOnlyValue;
break;
}
}
base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);
}
示例13: ReadActions
/// <summary>
/// Read all the actions that are children of the actions node
/// passed in and return a populated IResourceActions collection
/// </summary>
/// <param name="actionsNode">The actions node to be read</param>
/// <returns>Populated IResourceActions collection</returns>
private IResourceActions ReadActions(XPathNavigator actionsNode)
{
IResourceActions resourceActions = new ResourceActions();
XPathNodeIterator actionNodes = actionsNode.SelectChildren(@"Action", RESOURCE_NAMESPACE_URI);
if (actionNodes != null && actionNodes.Count > 0)
{
while (actionNodes.MoveNext())
{
XPathNavigator actionNode = actionNodes.Current;
// If the action is already in the resource actions, then
// overwrite it i.e. remove it first then add it in again
// OK so do it better and more efficiently later
IResourceAction resourceAction = ReadAction(actionNode);
if (resourceActions.Contains(resourceAction))
{
resourceActions.Remove(resourceAction);
}
resourceActions.Add(resourceAction);
// determine the custom data ui handler, probably should be done elsewhere
// merged with action loading actually
string customUItypeName = (resourceAction as ResourceAction).CustomDataTypeUITypeName;
if (customUItypeName != null)
{
string path = AssemblyLocation.GetPathForActionAssembly(resourceAction.Assembly);
try
{
Assembly assembly = AssemblyLocation.LoadAssemblyFromName(path);
resourceAction.CustomDataTypeUI = assembly.CreateInstance(customUItypeName) as ICustomDataType;
}
catch (Exception e)
{
StringBuilder sb = new StringBuilder();
sb.Append("XmlResourceReader.ReadAction, trying to load ICustomDataType. ");
sb.Append("Ignore exception - custom UI may fail to load because the designer is being used ");
sb.Append("from a workstation that doesnt have the action installed. This will be reflected in the designer UI to its user.");
Logger.LogDebug(sb.ToString());
Logger.LogDebug(e);
}
}
}
}
return resourceActions;
}
示例14: GrabBackDropUrls
public IList<string> GrabBackDropUrls(XPathNavigator nav)
{
List<string> urls = new List<string>();
XPathNodeIterator nIter = nav.SelectChildren("backdrop", "");
if (nav.MoveToFollowing("backdrop", ""))
{
XPathNavigator localNav = nav.CreateNavigator();
nav.MoveToParent();
for (int i = 0; i < nIter.Count; i++)
{
if (localNav.GetAttribute("size", "").ToUpperInvariant().Equals("original".ToUpperInvariant()))
urls.Add(localNav.Value);
localNav.MoveToNext();
}
}
return urls;
}
示例15: Parse
protected void Parse(XPathNavigator navigator)
{
XPathNodeIterator xpni = navigator.SelectChildren(XmlConstants.Property, XmlConstants.SchemaXMLNS);
while (xpni.MoveNext())
{
string propName = xpni.Current.GetAttribute(XmlConstants.Property_Name_Attribute, string.Empty);
int propEditLevel = 0;
Int32.TryParse(xpni.Current.GetAttribute(XmlConstants.Property_EditLevel_Attribute, string.Empty), out propEditLevel);
string propOptionValues =
xpni.Current.GetAttribute(XmlConstants.Property_OptionValues_Attribute, string.Empty);
string propValue = xpni.Current.Value;
if (!string.IsNullOrEmpty(propName) && !string.IsNullOrEmpty(propValue))
{
Property p = new Property(propName, propValue, propEditLevel, propOptionValues);
properties.Add(p);
}
}
}