Exemplo n.º 1
0
        public void CreateProperty()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IPropertyBuilder TestProperty = TestType.CreateProperty("TestProperty", typeof(int));

            Assert.NotNull(TestProperty);
            Assert.Equal("TestProperty", TestProperty.Name);
            Assert.Equal(typeof(int), TestProperty.DataType);
            Assert.NotNull(TestProperty.Builder);
            Assert.Equal(PropertyAttributes.SpecialName, TestProperty.Attributes);
            Assert.NotNull(TestProperty.GetMethod);
            Assert.NotNull(TestProperty.SetMethod);
            Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, TestProperty.GetMethodAttributes);
            Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, TestProperty.SetMethodAttributes);
        }
Exemplo n.º 2
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));
            Assert.DoesNotThrow(() => -- TestProperty);
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
            ++TestProperty;
        }