本文整理汇总了C#中System.Xml.Linq.XElement.Name方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.Name方法的具体用法?C# XElement.Name怎么用?C# XElement.Name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XElement
的用法示例。
在下文中一共展示了XElement.Name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareField
protected override bool CompareField(XElement field, Datagram datagram)
{
EthernetDatagram ethernetDatagram = (EthernetDatagram)datagram;
switch (field.Name())
{
case "eth.dst":
CompareEthernetAddress(field, ethernetDatagram.Destination);
break;
case "eth.src":
CompareEthernetAddress(field, ethernetDatagram.Source);
break;
case "eth.type":
field.AssertShowHex((ushort)ethernetDatagram.EtherType);
break;
case "eth.trailer":
if (ethernetDatagram.Trailer != null)
field.AssertValue(ethernetDatagram.Trailer);
break;
case "":
if (ethernetDatagram.Trailer != null)
field.AssertValue(ethernetDatagram.FrameCheckSequence);
break;
default:
throw new InvalidOperationException("Invalid etherent field " + field.Name());
}
return true;
}
示例2: CompareField
protected override bool CompareField(XElement field, Datagram parentDatagram, Datagram datagram)
{
IpDatagram ipDatagram = (IpDatagram)parentDatagram;
UdpDatagram udpDatagram = (UdpDatagram)datagram;
switch (field.Name())
{
case "udp.srcport":
field.AssertShowDecimal(udpDatagram.SourcePort);
break;
case "udp.dstport":
field.AssertShowDecimal(udpDatagram.DestinationPort);
break;
case "udp.port":
Assert.IsTrue(ushort.Parse(field.Show()) == udpDatagram.SourcePort ||
ushort.Parse(field.Show()) == udpDatagram.DestinationPort);
break;
case "udp.length":
field.AssertShowDecimal(udpDatagram.TotalLength);
break;
case "udp.checksum":
field.AssertShowDecimal(udpDatagram.Checksum);
if (udpDatagram.Checksum != 0)
{
foreach (var checksumField in field.Fields())
{
switch (checksumField.Name())
{
case "udp.checksum_good":
checksumField.AssertShowDecimal(ipDatagram.IsTransportChecksumCorrect);
break;
case "udp.checksum_bad":
if (checksumField.Show() == "1")
Assert.IsFalse(ipDatagram.IsTransportChecksumCorrect);
else
checksumField.AssertShowDecimal(0);
break;
}
}
}
break;
case "udp.checksum_coverage":
field.AssertShowDecimal(udpDatagram.TotalLength);
break;
case "udp.stream":
break;
default:
throw new InvalidOperationException("Invalid udp field " + field.Name());
}
return true;
}
示例3: CompareField
protected override bool CompareField(XElement field, Datagram datagram)
{
IpV6Datagram ipV6Datagram = datagram as IpV6Datagram;
if (ipV6Datagram == null)
return true;
while (_count > 0)
{
do
{
++_currentExtensionHeaderIndex;
if (_currentExtensionHeaderIndex >= ipV6Datagram.ExtensionHeaders.Headers.Count)
{
Assert.IsFalse(ipV6Datagram.ExtensionHeaders.IsValid);
return false;
}
} while (ipV6Datagram.ExtensionHeaders[_currentExtensionHeaderIndex].Protocol != IpV4Protocol.AuthenticationHeader);
--_count;
}
IpV6ExtensionHeaderAuthentication authenticationHeader = (IpV6ExtensionHeaderAuthentication)ipV6Datagram.ExtensionHeaders[_currentExtensionHeaderIndex];
switch (field.Name())
{
case "":
string[] headerFieldShowParts = field.Show().Split(':');
string headerFieldShowName = headerFieldShowParts[0];
string headerFieldShowValue = headerFieldShowParts[1];
switch (headerFieldShowName)
{
case "Next Header":
field.AssertValue((byte)authenticationHeader.NextHeader.Value);
break;
case "Length":
Assert.AreEqual(string.Format(" {0}", authenticationHeader.Length), headerFieldShowValue);
break;
default:
throw new InvalidOperationException("Invalid ipv6 authentication header unnamed field show name " + headerFieldShowName);
}
break;
case "ah.spi":
field.AssertShowDecimal(authenticationHeader.SecurityParametersIndex);
break;
case "ah.sequence":
field.AssertShowDecimal(authenticationHeader.SequenceNumber);
break;
case "ah.icv":
field.AssertValue(authenticationHeader.AuthenticationData);
break;
default:
throw new InvalidOperationException(string.Format("Invalid ipv6 authentication header field {0}", field.Name()));
}
return true;
}
示例4: CreateArglist
public static UnifiedSet<UnifiedArgument> CreateArglist(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "arglist");
/*
* arglist: (argument ',')* (argument [',']
* |'*' test (',' argument)* [',' '**' test]
* |'**' test)
*/
return node.Elements()
.Where(
e =>
e.Name() == "argument"
|| e.Name() == "test")
.Select(
e => e.Name() == "argument"
? CreateArgument(e)
: UnifiedArgument.Create(
CreateTest(e), null,
UnifiedModifier.Create(
e.PreviousElement().
Value).
ToSet()))
.ToSet();
}
示例5: CreateIterationStatement
public static UnifiedExpression CreateIterationStatement(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "iteration_statement");
/*
iteration_statement
: 'while' '(' expression ')' statement
| 'do' statement 'while' '(' expression ')' ';'
| 'for' '(' expression_statement expression_statement expression? ')' statement
*/
var first = node.FirstElement().Value;
var body =
UnifiedBlock.Create(
CreateStatement(node.FirstElement("statement")));
switch (first) {
case "while":
return UnifiedWhile.Create(CreateExpression(node.NthElement(2)), body);
case "do":
return UnifiedDoWhile.Create(CreateExpression(node.NthElement(4)), body);
case "for":
var step = node.Element("expression");
var stepExp = step != null ? CreateExpression(step) : null;
return UnifiedFor.Create(
CreateExpressionStatement(node.NthElement(2)),
CreateExpressionStatement(node.NthElement(3)),
stepExp, body);
default:
throw new InvalidOperationException();
}
}
示例6: CreateFloat
public static UnifiedExpression CreateFloat(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "Float");
return UnifiedFractionLiteral.Create(
double.Parse(node.Value),
UnifiedFractionLiteralKind.Double);
}
示例7: CreateArglist
public static UnifiedSet<UnifiedArgument> CreateArglist(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "arglist");
return node.Elements()
.Select(e => CreateExpresion(e).ToArgument())
.ToSet();
}
示例8: CreateBlock
public static UnifiedBlock CreateBlock(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "block");
return node.Elements()
.Select(CreateExpresion)
.ToBlock();
}
示例9: CreateAlias
public static UnifiedExpression CreateAlias(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "alias");
return UnifiedAlias.Create(
CreateExpresion(node.FirstElement()),
CreateExpresion(node.LastElement()));
}
示例10: CreateBignum
public static UnifiedExpression CreateBignum(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "Bignum");
return
UnifiedInt32Literal.Create(
LiteralFuzzyParser.ParseBigInteger(node.Value));
}
示例11: CreateFixnum
public static UnifiedExpression CreateFixnum(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "Fixnum");
return
UnifiedInt32Literal.Create(
NumberParser.ParseInt32(node.Value));
}
示例12: CreateIf
public static UnifiedIf CreateIf(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "if");
return UnifiedIf.Create(
CreateExpresion(node.NthElement(0)),
CreateBlock(node.NthElement(1)),
CreateBlock(node.NthElement(2)));
}
示例13: CreateModule
public static UnifiedClassDefinition CreateModule(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "module");
return UnifiedClassDefinition.Create(
null, null, CreateSymbol(node.NthElement(0)), null,
null,
CreateScope(node.NthElement(1)));
}
示例14: CreateBlock
public static UnifiedElement CreateBlock(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "block");
/*
* block : chunk;
*/
throw new NotImplementedException(); //TODO: implement
}
示例15: CreateBinop
public static UnifiedElement CreateBinop(XElement node)
{
Contract.Requires(node != null);
Contract.Requires(node.Name() == "binop");
/*
* binop : '+' | '-' | '*' | '/' | '^' | '%' | '..' |
*/
throw new NotImplementedException(); //TODO: implement
}