本文整理汇总了C#中Class.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# Class.AddChild方法的具体用法?C# Class.AddChild怎么用?C# Class.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class
的用法示例。
在下文中一共展示了Class.AddChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constant
public void Constant()
{
Constant con = new Constant(controller, "VALUE_1", new DataType(controller, "int"));
Assert.That(con.FullyQualifiedDisplayName, Is.EqualTo("VALUE_1"));
Class cl = new Class(controller, "Class1");
cl.AddChild(con);
Assert.That(con.FullyQualifiedDisplayName, Is.EqualTo("Class1.VALUE_1"));
}
示例2: Enumeration
public void Enumeration()
{
Enumeration item = new Enumeration(controller, "FileTypes");
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("FileTypes"));
Class cl = new Class(controller, "Class1");
cl.AddChild(item);
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.FileTypes"));
}
示例3: Delegate
public void Delegate()
{
Delegate item = new Delegate(controller, "Delegate1", new DataType(controller, "void"));
item.Parameters.Add(new Parameter(controller, "int", "i"));
item.Parameters.Add(new Parameter(controller, "string", "j"));
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Delegate1 (int, string)"));
Class cl = new Class(controller, "Class1");
cl.AddChild(item);
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.Delegate1 (int, string)"));
}
示例4: Constructor
public void Constructor()
{
Constructor con = new Constructor(controller, "Class1");
con.Parameters.Add(new Parameter(controller, "int", "i"));
con.Parameters.Add(new Parameter(controller, "string", "j"));
Assert.That(con.FullyQualifiedDisplayName, Is.EqualTo("Class1 (int, string)"));
Class cl = new Class(controller, "Class1");
cl.AddChild(con);
Assert.That(con.FullyQualifiedDisplayName, Is.EqualTo("Class1.Class1 (int, string)"));
}
示例5: EnumMember
public void EnumMember()
{
Enumeration en = new Enumeration(controller, "FileTypes");
Enumeration.EnumMember item = new Enumeration.EnumMember(controller, "CSharp");
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("CSharp"));
en.AddChild(item);
Class cl = new Class(controller, "Class1");
cl.AddChild(en);
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.FileTypes.CSharp"));
}
示例6: 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");
}
示例7: PropertyAccessor
public void PropertyAccessor()
{
Property itp = new Property(controller, "Property1", new DataType(controller, "int"), "public");
PropertyAccessor item1 = new PropertyAccessor(controller, ArchAngel.Providers.CodeProvider.DotNet.PropertyAccessor.AccessorTypes.Get);
PropertyAccessor item2 = new PropertyAccessor(controller, ArchAngel.Providers.CodeProvider.DotNet.PropertyAccessor.AccessorTypes.Set);
itp.AddChild(item1);
itp.AddChild(item2);
Assert.That(item1.FullyQualifiedDisplayName, Is.EqualTo("Property1.Get Accessor"));
Assert.That(item2.FullyQualifiedDisplayName, Is.EqualTo("Property1.Set Accessor"));
Class it = new Class(controller, "Class1");
it.AddChild(itp);
Assert.That(item1.FullyQualifiedDisplayName, Is.EqualTo("Class1.Property1.Get Accessor"));
Assert.That(item2.FullyQualifiedDisplayName, Is.EqualTo("Class1.Property1.Set Accessor"));
}
示例8: Indexer
public void Indexer()
{
Indexer item = new Indexer(controller);
item.Parameters.Add(new Parameter(controller, "float", "f"));
item.Parameters.Add(new Parameter(controller, "InputObject", "j"));
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Indexer [float, InputObject]"));
Class cl = new Class(controller, "Class1");
cl.AddChild(item);
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.Indexer [float, InputObject]"));
}
示例9: Operator
public void Operator()
{
Operator item = new Operator(controller, "+", new DataType(controller, "int"), "public");
item.Parameters.Add(new Parameter(controller, "Class1", "this"));
item.Parameters.Add(new Parameter(controller, "InputObject", "j"));
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("+ (Class1, InputObject)"));
Class cl = new Class(controller, "Class1");
cl.AddChild(item);
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.+ (Class1, InputObject)"));
}
示例10: Field
public void Field()
{
Field item = new Field(controller, new DataType(controller, "int"), "Field1", "public");
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Field1"));
Class cl = new Class(controller, "Class1");
cl.AddChild(item);
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.Field1"));
}
示例11: Function
public void Function()
{
Function item = new Function(controller, "Function1", new DataType(controller, "ReturnObjectOfSomeKind"));
item.Parameters.Add(new Parameter(controller, "float", "f"));
item.Parameters.Add(new Parameter(controller, "InputObject", "j"));
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Function1 (float, InputObject)"));
Class cl = new Class(controller, "Class1");
cl.AddChild(item);
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.Function1 (float, InputObject)"));
}
示例12: Event
public void Event()
{
Event item = new Event(controller, new DataType(controller, "Delegate1"), "Event1", "public");
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Event1"));
Class cl = new Class(controller, "Class1");
cl.AddChild(item);
Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.Event1"));
}
示例13: 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;
}
示例14: 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;
}
示例15: SetupFunctions
protected void SetupFunctions()
{
controller = new CSharpController();
func1 = CreateFunction("Function1", "i", 21);
func2 = CreateFunction("Function2", "j", 22);
func3 = CreateFunction("Function3", "k", 23);
func4 = CreateFunction("Function4", "l", 24);
Class cl = new Class(controller, "Class1");
cl.AddChild(func1);
cl.AddChild(func2);
cl.AddChild(func3);
cl.AddChild(func4);
controller.Root.AddChild(cl);
}