コード例 #1
0
 public void GetDefinition()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int));
     Assert.NotEmpty(Field.GetDefinition());
 }
コード例 #2
0
 public void CreateType()
 {
     Utilities.Reflection.Emit.Assembly TestObject = new Utilities.Reflection.Emit.Assembly("TestingThis");
     Utilities.Reflection.Emit.TypeBuilder TypeObject = TestObject.CreateType("TestClass");
     Assert.NotNull(TypeObject);
     TestObject.Create();
 }
コード例 #3
0
 public void GetDefinition()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.Interfaces.IPropertyBuilder Property = TestType.CreateDefaultProperty("Property1", typeof(int));
     Assert.NotEmpty(Property.GetDefinition());
 }
コード例 #4
0
 public void Call()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     Assert.DoesNotThrow(() => Local1.Call("ToString"));
 }
コード例 #5
0
 public void MinusMinus()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateConstructor();
     Utilities.Reflection.Emit.PropertyBuilder TestProperty = (Utilities.Reflection.Emit.PropertyBuilder)TestType.CreateProperty("TestProperty", typeof(int));
     --TestProperty;
 }
コード例 #6
0
 public void Call()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int));
     Assert.DoesNotThrow<Exception>(() => Field.Call("ToString"));
 }
コード例 #7
0
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Assert.NotNull(TestType);
     Assert.DoesNotThrow<Exception>(() => Assembly.Create());
     Assert.NotNull(Activator.CreateInstance(TestType.DefinedType));
 }
コード例 #8
0
 public void PlusPlus()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateConstructor();
     Utilities.Reflection.Emit.PropertyBuilder TestProperty = (Utilities.Reflection.Emit.PropertyBuilder)TestType.CreateProperty("TestProperty", typeof(int));
     Assert.DoesNotThrow(() => ++TestProperty);
 }
コード例 #9
0
 public void Save()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     Local1.Save(Method.Generator);
 }
コード例 #10
0
 public void Assign()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int));
     Assert.DoesNotThrow(() => Field.Assign(12));
 }
コード例 #11
0
 public void Load()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     Assert.DoesNotThrow<Exception>(() => Local1.Load(Method.Generator));
 }
コード例 #12
0
 public void Load()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int));
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     Field.Load(Method.Generator);
 }
コード例 #13
0
 public void Save()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateConstructor();
     Utilities.Reflection.Emit.PropertyBuilder TestProperty = (Utilities.Reflection.Emit.PropertyBuilder)TestType.CreateProperty("TestProperty", typeof(int));
     Assert.Throws<NullReferenceException>(() => TestProperty.Save(null));
     Assert.DoesNotThrow(() => TestProperty.Save(Method.Generator));
 }
コード例 #14
0
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.Interfaces.IMethodBuilder Constructor = TestType.CreateConstructor();
     VariableBase Constant = Constructor.CreateConstant(12);
     Assert.NotNull(Constant);
     Assert.Equal(typeof(int), Constant.DataType);
 }
コード例 #15
0
 public void Box()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     VariableBase Local2 = Method.CreateLocal("Local2", typeof(int));
     Assert.NotNull(Method.Box(Local1));
 }
コード例 #16
0
        public void Call()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));

            Assert.DoesNotThrow <Exception>(() => Local1.Call("ToString"));
        }
コード例 #17
0
        public void Assign()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");

            Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int));
            Assert.DoesNotThrow(() => Field.Assign(12));
        }
コード例 #18
0
 public void Load()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateConstructor();
     Assert.NotNull(Method.This);
     Assert.Null(Method.This.DataType);
     Assert.Equal("this", Method.This.Name);
     Method.This.Load(Method.Generator);
 }
コード例 #19
0
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     Assert.NotNull(Local1);
     Assert.Equal(typeof(int), Local1.DataType);
     Assert.Equal("Local1", Local1.Name);
 }
コード例 #20
0
        public void Create()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            Utilities.Reflection.Emit.Interfaces.IMethodBuilder Constructor = TestType.CreateConstructor();
            VariableBase Constant = Constructor.CreateConstant(12);

            Assert.NotNull(Constant);
            Assert.Equal(typeof(int), Constant.DataType);
        }
コード例 #21
0
        public void Return()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod", ReturnType: typeof(int));
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Assert.DoesNotThrow <Exception>(() => Method.Return(Local1));
        }
コード例 #22
0
ファイル: MethodBuilder.cs プロジェクト: ewin66/VilinCode
        public void Throw()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Method.Throw(Method.NewObj(typeof(Exception)));
        }
コード例 #23
0
 public void Save()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateConstructor();
     Assert.NotNull(Method.This);
     Assert.Null(Method.This.DataType);
     Assert.Equal("this", Method.This.Name);
     Assert.DoesNotThrow<Exception>(() => Method.This.Save(Method.Generator));
 }
コード例 #24
0
 public void Call()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     IMethodBuilder Method2 = TestType.CreateMethod("TestMethod2");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     VariableBase Local2 = Method.CreateLocal("Local2", typeof(int));
     Assert.DoesNotThrow<Exception>(() => Method.This.Call(Method2, null));
 }
コード例 #25
0
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.Interfaces.IMethodBuilder Constructor = TestType.CreateDefaultConstructor();
     Assert.NotNull(Constructor);
     Assert.Equal(MethodAttributes.Public, Constructor.Attributes);
     Assert.Null(Constructor.Generator);
     Assert.NotNull(Constructor.Parameters);
     Assert.Equal(1, Constructor.Parameters.Count);
 }
コード例 #26
0
ファイル: MethodBuilder.cs プロジェクト: ewin66/VilinCode
        public void Call()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method  = TestType.CreateMethod("TestMethod");
            IMethodBuilder Method2 = TestType.CreateMethod("TestMethod2");
            VariableBase   Local1  = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2  = Method.CreateLocal("Local2", typeof(int));

            Method.This.Call(Method2, null);
        }
コード例 #27
0
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int));
     Assert.NotNull(Field);
     Assert.Equal(typeof(int), Field.DataType);
     Assert.Equal("Field1", Field.Name);
     Assert.Equal(FieldAttributes.Public, Field.Attributes);
     Assert.NotNull(Field.Builder);
 }
コード例 #28
0
        public void Load()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateConstructor();

            Assert.NotNull(Method.This);
            Assert.Null(Method.This.DataType);
            Assert.Equal("this", Method.This.Name);
            Assert.DoesNotThrow <Exception>(() => Method.This.Load(Method.Generator));
        }
コード例 #29
0
 public void CreateConstructor()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder TestConstructor = TestType.CreateConstructor();
     Assert.NotNull(TestConstructor);
     Assert.Equal(MethodAttributes.Public, TestConstructor.Attributes);
     Assert.NotNull(TestConstructor.Generator);
     Assert.Null(TestConstructor.Name);
     Assert.Equal(1, TestConstructor.Parameters.Count);
     Assert.Null(TestConstructor.ReturnType);
     Assert.NotNull(TestConstructor.This);
 }
コード例 #30
0
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.Interfaces.IPropertyBuilder Property = TestType.CreateDefaultProperty("Property1", typeof(int));
     Assert.NotNull(Property);
     Assert.Equal(typeof(int), Property.DataType);
     Assert.Equal("Property1", Property.Name);
     Assert.Equal(PropertyAttributes.SpecialName, Property.Attributes);
     Assert.NotNull(Property.GetMethod);
     Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, Property.GetMethodAttributes);
     Assert.NotNull(Property.SetMethod);
     Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, Property.SetMethodAttributes);
     Assert.NotNull(Property.Builder);
 }
コード例 #31
0
 public void CreateMethod()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.Interfaces.IMethodBuilder TestMethod = TestType.CreateMethod("TestMethod");
     Assert.NotNull(TestMethod);
     Assert.Equal("TestMethod", TestMethod.Name);
     Assert.Equal(typeof(void), TestMethod.ReturnType);
     Assert.NotNull(TestMethod.Generator);
     Assert.NotNull(TestMethod.This);
     Assert.Equal(1, TestMethod.Parameters.Count);
     Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, TestMethod.Attributes);
 }
コード例 #32
0
 public void Return()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod", ReturnType: typeof(int));
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     VariableBase Local2 = Method.CreateLocal("Local2", typeof(int));
     Assert.DoesNotThrow(() => Method.Return(Local1));
 }
コード例 #33
0
 public void While()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     VariableBase Local2 = Method.CreateLocal("Local2", typeof(int));
     Utilities.Reflection.Emit.Commands.While While = Method.While(Local1, Utilities.Reflection.Emit.Enums.Comparison.Equal, Local2);
     Method.EndWhile(While);
     Assert.NotNull(While);
 }
コード例 #34
0
 public void TryCatch()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     VariableBase Local2 = Method.CreateLocal("Local2", typeof(int));
     Utilities.Reflection.Emit.Commands.Try Try = Method.Try();
     Utilities.Reflection.Emit.Commands.Catch Catch = Method.Catch(typeof(Exception));
     Method.EndTry();
     Assert.NotNull(Try);
     Assert.NotNull(Catch);
 }
コード例 #35
0
 public void NewObj()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     VariableBase Local2 = Method.CreateLocal("Local2", typeof(int));
     Assert.NotNull(Method.NewObj(typeof(DateTime), new object[] { Local1 }));
 }
コード例 #36
0
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     Assert.NotNull(Method);
 }
コード例 #37
0
 public void Throw()
 {
     Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     IMethodBuilder Method = TestType.CreateMethod("TestMethod");
     VariableBase Local1 = Method.CreateLocal("Local1", typeof(int));
     VariableBase Local2 = Method.CreateLocal("Local2", typeof(int));
     Assert.DoesNotThrow(() => Method.Throw(Method.NewObj(typeof(Exception))));
 }