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


C# Class.AddAttributeSection方法代码示例

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


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

示例1: Class

        public void Class()
        {
            Class cl = new Class(controller, "Class1");
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            AttributeSection attrs = new AttributeSection(controller);
            Attribute attr = new Attribute(controller);
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            CodeRoot root = new CodeRoot(controller);
            root.AddChild(ns);
            CodeRootMap map = new CodeRootMap();
            map.AddCodeRoot(root, Version.User);
            map.AddCodeRoot(root, Version.NewGen);
            map.AddCodeRoot(root, Version.PrevGen);

            string result = map.GetMergedCodeRoot().ToString();
            Assert.That(result, Is.EqualTo(root.ToString()));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:27,代码来源:Specs_For_CodeRootMap_Merge.cs

示例2: Attribute

        public void Attribute()
        {
            Attribute attr = new Attribute(controller);
            attr.Name = "Test";

            Assert.That(attr.FullyQualifiedIdentifer, Is.EqualTo("[Test]"));

            AttributeSection attrSec = new AttributeSection(controller);
            attrSec.AddChild(attr);
            Class cl = new Class(controller, "Class1");
            cl.AddAttributeSection(attrSec);

            Assert.That(attr.FullyQualifiedIdentifer, Is.EqualTo("Class1|[Test]"));
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:14,代码来源:Specs_For_CSharp_BaseConstructs_UID.cs

示例3: AddLinkingAttribute

    /// <summary>
    /// Adds the linking attribute.
    /// </summary>
    /// <param name="contractClass">The contract class.</param>
    private void AddLinkingAttribute(Class contractClass)
    {
      Contract.Requires(contractClass != null, "contractClass must not be null.");

      var typeOfExp = new TypeOfExpression(new TypeReferenceExpression(this.InterfaceName));
      var attribute = new CustomAttribute() { Name = ContractClassFor };
      if (attribute.Arguments != null)
      {
        attribute.Arguments.Add(typeOfExp);
      }

      var section = new AttributeSection();
      if (section.AttributeCollection != null)
      {
        section.AttributeCollection.Add(attribute);
      }

      contractClass.AddAttributeSection(section);
    }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:23,代码来源:ContractClassBuilder.cs

示例4: GetPrevGenOrNewGenRoot

        private CodeRoot GetPrevGenOrNewGenRoot()
        {
            Class cl = new Class(controller, "Class1");
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            AttributeSection attrs = new AttributeSection(controller);
            Attribute attr = new Attribute(controller);
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);

            // Create another class to match to the user one.
            Class c3 = new Class(controller, "Class3");

            Namespace ns = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            ns.AddChild(c3);
            CodeRoot root = new CodeRoot(controller);
            root.AddChild(ns);
            return root;
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:23,代码来源:Specs_For_CodeRootMap_Matching.cs

示例5: Matching_Successful

        public void Matching_Successful()
        {
            controller.Reorder = true;
            Class cl = new Class(controller, "Class1");
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            Class c2 = new Class(controller, "Class2"); // Extra class in user
            AttributeSection attrs = new AttributeSection(controller);
            Attribute attr = new Attribute(controller);
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            ns.AddChild(c2);
            CodeRoot root = new CodeRoot(controller);
            root.AddChild(ns);

            CodeRootMap map = new CodeRootMap();
            map.AddCodeRoot(root, Version.User);

            root = GetPrevGenOrNewGenRoot();
            map.AddCodeRoot(root, Version.PrevGen);

            root = GetPrevGenOrNewGenRoot();
            map.AddCodeRoot(root, Version.NewGen);

            bool matchResult = map.MatchConstructs("ArchAngel.Tests|Class2", "ArchAngel.Tests|Class3", "ArchAngel.Tests|Class3");

            Assert.That(matchResult, Is.True);

            string result = map.GetMergedCodeRoot().ToString();
            Assert.That(map.Diff(), Is.EqualTo(TypeOfDiff.UserChangeOnly));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
            Assertions.StringContains(result, "Class2");
            Assertions.StringContains(result, "Class3", 0);
            int count = 0;
            foreach (CodeRootMapNode node in map.AllNodes)
            {
                if (node.IsTheSameReference(c2))
                    count++;
            }
            Assert.That(count, Is.EqualTo(1));
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:48,代码来源:Specs_For_CodeRootMap_Matching.cs

示例6: CreateClassAndNamespace

 protected CodeRoot CreateClassAndNamespace(IEnumerable<IBaseConstruct> children)
 {
     Class cl = new Class(controller, "Class1");
     foreach(IBaseConstruct child in children)
         cl.AddChild(child);
     cl.Index = 10;
     AttributeSection attrs = new AttributeSection(controller);
     attrs.Index = 5;
     Attribute attr = new Attribute(controller);
     attr.Index = 6;
     attr.PositionalArguments.Add("true");
     attr.Name = "Serializable";
     attrs.AddAttribute(attr);
     cl.AddAttributeSection(attrs);
     Namespace ns = new Namespace(controller);
     ns.Index = 0;
     ns.Name = "ArchAngel.Tests";
     ns.AddChild(cl);
     CodeRoot userRoot = new CodeRoot(controller);
     userRoot.AddChild(ns);
     return userRoot;
 }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:22,代码来源:Specs_For_CodeRootMap_Merge.cs

示例7: ConstructRootWithClass

 protected CodeRoot ConstructRootWithClass(IBaseConstruct childOfClass)
 {
     Class cl = new Class(controller, "Class1");
     cl.AddChild(childOfClass);
     AttributeSection attrs = new AttributeSection(controller);
     Attribute attr = new Attribute(controller);
     attr.PositionalArguments.Add("true");
     attr.Name = "Serializable";
     attrs.AddAttribute(attr);
     cl.AddAttributeSection(attrs);
     Namespace ns = new Namespace(controller);
     ns.Name = "ArchAngel.Tests";
     ns.AddChild(cl);
     CodeRoot root = new CodeRoot(controller);
     root.AddChild(ns);
     return root;
 }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:17,代码来源:Specs_For_CodeRootMap_Merge.cs

示例8: User_Is_Missing_Others_Are_Exact_Copy

        public void User_Is_Missing_Others_Are_Exact_Copy()
        {
            Function func = new Function(controller);
            func.Name = "Method1";
            func.Modifiers.Add("public");
            func.ReturnType = new DataType(controller, "void");
            func.BodyText = "{ }";

            Class cl = new Class(controller, "Class1");
            cl.AddChild(func);
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            AttributeSection attrs = new AttributeSection(controller);
            Attribute attr = new Attribute(controller);
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            CodeRoot root = new CodeRoot(controller);
            root.AddChild(ns);
            CodeRootMap map = new CodeRootMap();
            map.AddCodeRoot(root, Version.PrevGen);
            map.AddCodeRoot(root, Version.NewGen);

            string result = map.GetMergedCodeRoot().ToString();
            Assert.That(result, Is.EqualTo(root.ToString()));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "public void Method1()");
            Assertions.StringContains(result, "{ }");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:35,代码来源:Specs_For_CodeRootMap_Merge.cs

示例9: PrevGen_Is_Skipped_Where_No_Template_Or_User_Exist

        public void PrevGen_Is_Skipped_Where_No_Template_Or_User_Exist()
        {
            Class cl = new Class(controller, "Class1");
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            Class c2 = new Class(controller, "Class2"); // Extra class in prevgen
            AttributeSection attrs = new AttributeSection(controller);
            Attribute attr = new Attribute(controller);
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            ns.AddChild(c2);
            CodeRoot root = new CodeRoot(controller);
            root.AddChild(ns);

            CodeRootMap map = new CodeRootMap();
            map.AddCodeRoot(root, Version.PrevGen);

            cl = new Class(controller, "Class1");
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            attrs = new AttributeSection(controller);
            attr = new Attribute(controller);
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            ns = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            root = new CodeRoot(controller);
            root.AddChild(ns);

            map.AddCodeRoot(root, Version.User);
            map.AddCodeRoot(root, Version.NewGen);

            string result = map.GetMergedCodeRoot().ToString();
            Assert.That(result, Is.EqualTo(root.ToString()));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
            // make sure that the deleted class Class2 was not included int he merged code root.
            Assertions.StringContains(result, "Class2", 0);
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:48,代码来源:Specs_For_CodeRootMap_Merge.cs


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