当前位置: 首页>>代码示例>>C#>>正文


C# XMLToken.hasAttr方法代码示例

本文整理汇总了C#中libsbmlcs.XMLToken.hasAttr方法的典型用法代码示例。如果您正苦于以下问题:C# XMLToken.hasAttr方法的具体用法?C# XMLToken.hasAttr怎么用?C# XMLToken.hasAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libsbmlcs.XMLToken的用法示例。


在下文中一共展示了XMLToken.hasAttr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: test_XMLToken_attribute_add_remove

 public void test_XMLToken_attribute_add_remove()
 {
     XMLTriple triple = new  XMLTriple("test","","");
       XMLAttributes attr = new  XMLAttributes();
       XMLToken token = new  XMLToken(triple,attr);
       XMLTriple xt1 = new  XMLTriple("name1", "http://name1.org/", "p1");
       XMLTriple xt2 = new  XMLTriple("name2", "http://name2.org/", "p2");
       XMLTriple xt3 = new  XMLTriple("name3", "http://name3.org/", "p3");
       XMLTriple xt1a = new  XMLTriple("name1", "http://name1a.org/", "p1a");
       XMLTriple xt2a = new  XMLTriple("name2", "http://name2a.org/", "p2a");
       token.addAttr( "name1", "val1", "http://name1.org/", "p1");
       token.addAttr(xt2, "val2");
       assertTrue( token.getAttributesLength() == 2 );
       assertTrue( token.isAttributesEmpty() == false );
       assertTrue( (  "name1" != token.getAttrName(0) ) == false );
       assertTrue( (  "val1"  != token.getAttrValue(0) ) == false );
       assertTrue( (  "http://name1.org/" != token.getAttrURI(0) ) == false );
       assertTrue( (  "p1"    != token.getAttrPrefix(0) ) == false );
       assertTrue( (  "name2" != token.getAttrName(1) ) == false );
       assertTrue( (  "val2"  != token.getAttrValue(1) ) == false );
       assertTrue( (  "http://name2.org/" != token.getAttrURI(1) ) == false );
       assertTrue( (  "p2"    != token.getAttrPrefix(1) ) == false );
       assertTrue( token.getAttrValue( "name1") == "" );
       assertTrue( token.getAttrValue( "name2") == "" );
       assertTrue( (  "val1"  != token.getAttrValue( "name1", "http://name1.org/") ) == false );
       assertTrue( (  "val2"  != token.getAttrValue( "name2", "http://name2.org/") ) == false );
       assertTrue( (  "val1"  != token.getAttrValue(xt1) ) == false );
       assertTrue( (  "val2"  != token.getAttrValue(xt2) ) == false );
       assertTrue( token.hasAttr(-1) == false );
       assertTrue( token.hasAttr(2) == false );
       assertTrue( token.hasAttr(0) == true );
       assertTrue( token.hasAttr( "name1", "http://name1.org/") == true );
       assertTrue( token.hasAttr( "name2", "http://name2.org/") == true );
       assertTrue( token.hasAttr( "name3", "http://name3.org/") == false );
       assertTrue( token.hasAttr(xt1) == true );
       assertTrue( token.hasAttr(xt2) == true );
       assertTrue( token.hasAttr(xt3) == false );
       token.addAttr( "noprefix", "val3");
       assertTrue( token.getAttributesLength() == 3 );
       assertTrue( token.isAttributesEmpty() == false );
       assertTrue( (  "noprefix" != token.getAttrName(2) ) == false );
       assertTrue( (  "val3"     != token.getAttrValue(2) ) == false );
       assertTrue( token.getAttrURI(2) == "" );
       assertTrue( token.getAttrPrefix(2) == "" );
       assertTrue( (      "val3"  != token.getAttrValue( "noprefix") ) == false );
       assertTrue( (  "val3"  != token.getAttrValue( "noprefix", "") ) == false );
       assertTrue( token.hasAttr( "noprefix"    ) == true );
       assertTrue( token.hasAttr( "noprefix", "") == true );
       token.addAttr(xt1, "mval1");
       token.addAttr( "name2", "mval2", "http://name2.org/", "p2");
       assertTrue( token.getAttributesLength() == 3 );
       assertTrue( token.isAttributesEmpty() == false );
       assertTrue( (  "name1" != token.getAttrName(0) ) == false );
       assertTrue( (  "mval1" != token.getAttrValue(0) ) == false );
       assertTrue( (  "http://name1.org/" != token.getAttrURI(0) ) == false );
       assertTrue( (  "p1"    != token.getAttrPrefix(0) ) == false );
       assertTrue( (  "name2"    != token.getAttrName(1) ) == false );
       assertTrue( (  "mval2"    != token.getAttrValue(1) ) == false );
       assertTrue( (  "http://name2.org/" != token.getAttrURI(1) ) == false );
       assertTrue( (  "p2"       != token.getAttrPrefix(1) ) == false );
       assertTrue( token.hasAttr(xt1) == true );
       assertTrue( token.hasAttr( "name1", "http://name1.org/") == true );
       token.addAttr( "noprefix", "mval3");
       assertTrue( token.getAttributesLength() == 3 );
       assertTrue( token.isAttributesEmpty() == false );
       assertTrue( (  "noprefix" != token.getAttrName(2) ) == false );
       assertTrue( (  "mval3"    != token.getAttrValue(2) ) == false );
       assertTrue( token.getAttrURI(2) == "" );
       assertTrue( token.getAttrPrefix(2) == "" );
       assertTrue( token.hasAttr( "noprefix") == true );
       assertTrue( token.hasAttr( "noprefix", "") == true );
       token.addAttr(xt1a, "val1a");
       token.addAttr(xt2a, "val2a");
       assertTrue( token.getAttributesLength() == 5 );
       assertTrue( (  "name1" != token.getAttrName(3) ) == false );
       assertTrue( (  "val1a" != token.getAttrValue(3) ) == false );
       assertTrue( (  "http://name1a.org/" != token.getAttrURI(3) ) == false );
       assertTrue( (  "p1a" != token.getAttrPrefix(3) ) == false );
       assertTrue( (  "name2" != token.getAttrName(4) ) == false );
       assertTrue( (  "val2a" != token.getAttrValue(4) ) == false );
       assertTrue( (  "http://name2a.org/" != token.getAttrURI(4) ) == false );
       assertTrue( (  "p2a" != token.getAttrPrefix(4) ) == false );
       assertTrue( (  "val1a"  != token.getAttrValue( "name1", "http://name1a.org/") ) == false );
       assertTrue( (  "val2a"  != token.getAttrValue( "name2", "http://name2a.org/") ) == false );
       assertTrue( (  "val1a"  != token.getAttrValue(xt1a) ) == false );
       assertTrue( (  "val2a"  != token.getAttrValue(xt2a) ) == false );
       token.removeAttr(xt1a);
       token.removeAttr(xt2a);
       assertTrue( token.getAttributesLength() == 3 );
       token.removeAttr( "name1", "http://name1.org/");
       assertTrue( token.getAttributesLength() == 2 );
       assertTrue( token.isAttributesEmpty() == false );
       assertTrue( (  "name2" != token.getAttrName(0) ) == false );
       assertTrue( (  "mval2" != token.getAttrValue(0) ) == false );
       assertTrue( (  "http://name2.org/" != token.getAttrURI(0) ) == false );
       assertTrue( (  "p2" != token.getAttrPrefix(0) ) == false );
       assertTrue( (  "noprefix" != token.getAttrName(1) ) == false );
       assertTrue( (  "mval3" != token.getAttrValue(1) ) == false );
       assertTrue( token.getAttrURI(1) == "" );
       assertTrue( token.getAttrPrefix(1) == "" );
//.........这里部分代码省略.........
开发者ID:0u812,项目名称:roadrunner-backup,代码行数:101,代码来源:TestXMLToken.cs


注:本文中的libsbmlcs.XMLToken.hasAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。