本文整理汇总了C#中CompilationUnit.GetNamespaceContents方法的典型用法代码示例。如果您正苦于以下问题:C# CompilationUnit.GetNamespaceContents方法的具体用法?C# CompilationUnit.GetNamespaceContents怎么用?C# CompilationUnit.GetNamespaceContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompilationUnit
的用法示例。
在下文中一共展示了CompilationUnit.GetNamespaceContents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetNamespaceContentsCase2
public void TestGetNamespaceContentsCase2 ()
{
CompilationUnit unit = new CompilationUnit ("file.cs");
unit.Add (new DomType ("ANamespace.AnotherNamespace.AClass"));
unit.Add (new DomType ("ANamespace.AnotherNamespace.BClass"));
unit.Add (new DomType ("ANamespace.AnotherNamespace.CClass"));
unit.Add (new DomType ("ANamespace.AClass2"));
unit.Add (new DomType ("ANamespace.BClass2"));
unit.Add (new DomType ("CClass3"));
List<IMember> member = new List<IMember> ();
unit.GetNamespaceContents (member, "ANamespace", true);
Assert.AreEqual (3, member.Count);
Namespace ns = member[0] as Namespace;
Assert.IsNotNull (ns);
Assert.AreEqual ("AnotherNamespace", ns.Name);
IType type = member[1] as IType;
Assert.IsNotNull (type);
Assert.AreEqual ("AClass2", type.Name);
type = member[2] as IType;
Assert.IsNotNull (type);
Assert.AreEqual ("BClass2", type.Name);
}
示例2: TestGetNamespaceContentsCase4
public void TestGetNamespaceContentsCase4 ()
{
CompilationUnit unit = new CompilationUnit ("file.cs");
unit.Add (new DomType ("ANamespace.AnotherNamespace.AClass"));
unit.Add (new DomType ("ANamespace.AnotherNamespace.BClass"));
unit.Add (new DomType ("ANamespace.AnotherNamespace.CClass"));
unit.Add (new DomType ("ANamespace.AClass2"));
unit.Add (new DomType ("ANamespace.BClass2"));
unit.Add (new DomType ("CClass3"));
List<IMember> member = new List<IMember> ();
unit.GetNamespaceContents (member, "ANamespace.NotExist", true);
Assert.AreEqual (0, member.Count);
}