本文整理汇总了C#中System.Xml.XmlNode.GetOptionalAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.GetOptionalAttribute方法的具体用法?C# XmlNode.GetOptionalAttribute怎么用?C# XmlNode.GetOptionalAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.GetOptionalAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parses the condition.
/// </summary>
/// <param name="node">The node to parse.</param>
/// <returns>The condition parsed, or null if nothing parsed.</returns>
public IRewriteCondition Parse(XmlNode node)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
string method = node.GetOptionalAttribute(Constants.AttrMethod);
if (method == null)
{
return null;
}
return new MethodCondition(method);
}
示例2: Parse
/// <summary>
/// Parses the condition.
/// </summary>
/// <param name="node">The node to parse.</param>
/// <returns>The condition parsed, or null if nothing parsed.</returns>
public IRewriteCondition Parse(XmlNode node)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
string exists = node.GetOptionalAttribute(Constants.AttrExists);
if (exists == null)
{
return null;
}
return new ExistsCondition(exists);
}
示例3: Parse
/// <summary>
/// Parses the condition.
/// </summary>
/// <param name="node">The node to parse.</param>
/// <returns>The condition parsed, or null if nothing parsed.</returns>
public IRewriteCondition Parse(XmlNode node)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
string urlPattern = node.GetOptionalAttribute(Constants.AttrUrl);
if (urlPattern == null)
{
return null;
}
return new UrlMatchCondition(urlPattern);
}
示例4: Parse
/// <summary>
/// Parses the condition.
/// </summary>
/// <param name="node">The node to parse.</param>
/// <returns>The condition parsed, or null if nothing parsed.</returns>
public IRewriteCondition Parse(XmlNode node)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
string header = node.GetOptionalAttribute(Constants.AttrHeader);
if (header == null)
{
return null;
}
string match = node.GetRequiredAttribute(Constants.AttrMatch, true);
return new PropertyMatchCondition(header, match);
}
示例5: Parse
/// <summary>
/// Parses the node.
/// </summary>
/// <param name="node">The node to parse.</param>
/// <param name="config">The rewriter configuration.</param>
/// <returns>The parsed action, or null if no action parsed.</returns>
public override IRewriteAction Parse(XmlNode node, IRewriterConfiguration config)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
if (config == null)
{
throw new ArgumentNullException("config");
}
string headerName = node.GetOptionalAttribute(Constants.AttrHeader);
if (headerName == null)
{
return null;
}
string headerValue = node.GetRequiredAttribute(Constants.AttrValue, true);
return new AddHeaderAction(headerName, headerValue);
}
示例6: Parse
/// <summary>
/// Parses the node.
/// </summary>
/// <param name="node">The node to parse.</param>
/// <param name="config">The rewriter configuration.</param>
/// <returns>The parsed action, or null if no action parsed.</returns>
public override IRewriteAction Parse(XmlNode node, IRewriterConfiguration config)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
if (config == null)
{
throw new ArgumentNullException("config");
}
string cookieName = node.GetOptionalAttribute(Constants.AttrCookie);
if (String.IsNullOrEmpty(cookieName))
{
return null;
}
string cookieValue = node.GetRequiredAttribute(Constants.AttrValue, true);
return new SetCookieAction(cookieName, cookieValue);
}
示例7: ParseProcessing
private RewriteProcessing ParseProcessing(XmlNode node)
{
string processing = node.GetOptionalAttribute(Constants.AttrProcessing);
if (processing == null)
{
// Default to ContinueProcessing if processing attribute is missing.
return RewriteProcessing.ContinueProcessing;
}
switch (processing)
{
case Constants.AttrValueRestart:
return RewriteProcessing.RestartProcessing;
case Constants.AttrValueStop:
return RewriteProcessing.StopProcessing;
case Constants.AttrValueContinue:
return RewriteProcessing.ContinueProcessing;
default:
throw new ConfigurationErrorsException(MessageProvider.FormatString(Message.ValueOfProcessingAttribute, processing, Constants.AttrValueContinue, Constants.AttrValueRestart, Constants.AttrValueStop), node);
}
}