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


C# Namespace.GetFullName方法代码示例

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


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

示例1: TestClassFullName

        public void TestClassFullName()
        {
            Namespace n = new Namespace(null, null);
            n.Name = "foo";

            Class c = new Class(null, null);
            c.UnqualifiedName = "bar";
            Console.WriteLine(c.GetQualifiedName());
            Assert.AreEqual("foo", n.Name, "namespace name1");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name1");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name1");
            Assert.AreEqual("bar", c.GetQualifiedName(), "class full name1");

            c.ParentExpression = n;
            Assert.AreEqual("foo", n.Name, "namespace name2");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name2");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name2");
            Assert.AreEqual("foo.bar", c.GetQualifiedName(), "class full name2");

            c.ParentExpression = new Expression(null, null);
            Assert.AreEqual("foo", n.Name, "namespace name3");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name3");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name3");
            Assert.AreEqual("bar", c.GetQualifiedName(), "class full name3");
        }
开发者ID:maleficus1234,项目名称:Pie,代码行数:25,代码来源:CoverageTests.cs

示例2: Emit

        // Generates a codedom namespace and attaches it to the compile unit (the root of the tree)
        public static void Emit(CodeCompileUnit codeCompileUnit, Namespace ns)
        {
            // Create the codedom namespace expression
            var codeNamespace = new CodeNamespace();

            // Assign the namespace name.
            codeNamespace.Name = ns.GetFullName();

            // Attach it to the root of the codedom tree.
            codeCompileUnit.Namespaces.Add(codeNamespace);

            // Create and attach the children of the namespace: classes, delegates, other namespaces, etc.
            foreach (var e in ns.ChildExpressions)
            {
                if (e is Namespace)
                    Emit(codeCompileUnit, (Namespace)e);
                if (e is Class)
                    ClassEmitter.Emit(codeNamespace, (Class)e);
                if (e is Import)
                {
                    var i = e as Import;
                    if (i.IsType) // Are we importing a class, enum, interface, struct, module?
                        codeNamespace.Imports.Add(new CodeNamespaceImport((e as Import).GetNamespace()));
                    else
                        codeNamespace.Imports.Add(new CodeNamespaceImport((e as Import).Name));
                }
                if (e is Pie.Expressions.Enum)
                    EnumEmitter.Emit(codeNamespace, e as Pie.Expressions.Enum);
                if (e is DelegateDeclaration)
                    DelegateEmitter.Emit(codeNamespace, e as DelegateDeclaration);
                if (e is Interface)
                    InterfaceEmitter.Emit(codeNamespace, e as Interface);
            }
        }
开发者ID:maleficus1234,项目名称:Pie,代码行数:35,代码来源:NamespaceEmitter.cs


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