本文整理汇总了C#中Parser.ParseGlobalAttrs方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.ParseGlobalAttrs方法的具体用法?C# Parser.ParseGlobalAttrs怎么用?C# Parser.ParseGlobalAttrs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.ParseGlobalAttrs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGlobalAttrs5
public void TestGlobalAttrs5()
{
var parser = new Parser("[assembly: Foo(1, 2)] [module: Bar(\"\", \"\")]");
var sects = parser.ParseGlobalAttrs();
Assert.AreEqual(2, sects.Count);
var sect1 = sects[0];
var sect2 = sects[1];
Assert.AreEqual(1, sect1.Attrs.Count);
Assert.AreEqual(1, sect2.Attrs.Count);
}
示例2: TestGlobalAttrs4
public void TestGlobalAttrs4()
{
var parser = new Parser("[assembly: FooAttribute(1, 2, Name=\"whatever\")]");
var attrs = parser.ParseGlobalAttrs();
Assert.AreEqual(1, attrs.Count);
var sect = attrs[0];
Assert.AreEqual(1, sect.Attrs.Count);
var fa = sect.Attrs[0];
Assert.AreEqual(3, fa.Args.Count);
Assert.IsTrue(fa.Args[0] is PositionalAttrArgument);
Assert.IsTrue(fa.Args[1] is PositionalAttrArgument);
var na = fa.Args[2] as NamedAttrArgument;
Assert.IsNotNull(na);
Assert.AreEqual("Name", na.Name.Spelling.Value);
}
示例3: TestGlobalAttrs2
public void TestGlobalAttrs2()
{
var parser = new Parser("[module: FooAttribute, Something.Else.BarAttribute]");
var attrs = parser.ParseGlobalAttrs();
Assert.AreEqual(1, attrs.Count);
var sect = attrs[0];
var fa = sect.Attrs[0];
var ba = sect.Attrs[1];
Assert.IsTrue(fa.AttrTypeName.PartsAre("FooAttribute"));
Assert.IsTrue(ba.AttrTypeName.PartsAre("Something", "Else", "BarAttribute"));
}
示例4: TestGlobalAttrs3
public void TestGlobalAttrs3()
{
var parser = new Parser("[assembly: Foo(1, 2, Arg=\"blah\"), Bar(Prop='c')]");
var sections = parser.ParseGlobalAttrs();
Assert.AreEqual(1, sections.Count);
var sect = sections[0];
Assert.AreEqual(2, sect.Attrs.Count);
var fa = sect.Attrs[0];
var fb = sect.Attrs[1];
Assert.IsTrue(fa.AttrTypeName.PartsAre("Foo"));
Assert.IsTrue(fb.AttrTypeName.PartsAre("Bar"));
Assert.AreEqual(3, fa.Args.Count);
Assert.AreEqual(1, fb.Args.Count);
Assert.IsTrue(fa.Args[0] is PositionalAttrArgument);
Assert.IsTrue(fa.Args[1] is PositionalAttrArgument);
Assert.IsTrue(fa.Args[2] is NamedAttrArgument);
var bArg = fb.Args[0] as NamedAttrArgument;
Assert.IsNotNull(bArg);
Assert.AreEqual("Prop", bArg.Name.Spelling.Value);
Assert.IsTrue(bArg.Exp is CharLiteralExp);
}
示例5: TestGlobalAttrs1
public void TestGlobalAttrs1()
{
var parser = new Parser("[assembly: CLSCompliant]");
var attrs = parser.ParseGlobalAttrs();
Assert.AreEqual(1, attrs.Count);
}