1: Utilities.Reflection.Emit.Assembly TempAssembly = new Utilities.Reflection.Emit.Assembly("TestAssembly", @"C:\Test\");
2: {
3: TypeBuilder Builder = TempAssembly.CreateType("Test.A");
4: {
5: FieldBuilder Field = Builder.CreateField("Field1", typeof(int));
6: FieldBuilder Field2 = Builder.CreateField("Field2", typeof(int));
7:
8: IMethodBuilder Constructor = Builder.CreateConstructor();
9: {
10: Constructor.Assign(Field, 19);
11: Constructor.Assign(Field2, Field);
12: Constructor.Return();
13: }
14:
15: IMethodBuilder Method = Builder.CreateMethod("Method1",
16: ReturnType: typeof(List<string>));
17: {
18: IVariable ReturnObj = Method.NewObj(typeof(List<string>).GetConstructor(Type.EmptyTypes), new List<IVariable>());
19: List<IVariable> Parameters = new List<IVariable>();
20: IVariable Val1=Method.CreateLocal("Val1",typeof(int));
21: Val1.Assign(Method,0);
22: Utilities.Reflection.Emit.Commands.While While=Method.While(Utilities.Reflection.Emit.Enums.Comparison.NotEqual, Method.CreateConstant(3), Val1);
23: {
24: Parameters = new List<IVariable>();
25: Parameters.Add(Method.CreateConstant("Test"));
26: Method.Call(ReturnObj, typeof(List<string>).GetMethod("Add"), Parameters);
27: Val1.Assign(Method, 3);
28: }
29: While.EndWhile();
30: Method.Return(ReturnObj);
31: }
32:
33: IMethodBuilder Method2 = Builder.CreateMethod("Method2", ReturnType: typeof(List<string>));
34: {
35: IVariable ReturnVal=Method2.Call(Method2.Parameters[0], ((MethodBuilder)Method).Builder, new List<IVariable>());
36: Method2.Return(ReturnVal);
37: }
38:
39: IPropertyBuilder Property = Builder.CreateDefaultProperty("Property1", typeof(Dictionary<string,string>));
40: }
41:
42: EnumBuilder Enum = TempAssembly.CreateEnum("Test.EnumTest", typeof(Int32));
43: {
44: Enum.AddLiteral("Entry1", 1);
45: Enum.AddLiteral("Entry2", 2);
46: Enum.AddLiteral("Entry3", 3);
47: }
48: }
49: TempAssembly.Create();