コード例 #1
0
        public void GetCustomAttributes4()
        {
            var c = new CustomAttributesTest();
            var x = c.GetType().GetProperty("P4").GetCustomAttributes <CustomAttributeAttribute>(false);

            Assert.Equal(2, x.Length);
        }
コード例 #2
0
        public void GetCustomAttributes3()
        {
            var c = new CustomAttributesTest();
            var x = c.GetType().GetProperty("P3").GetCustomAttributes <CustomAttributeAttribute>(false);

            Assert.Equal(1, x.Length);
            Assert.Equal("Foo", x.ElementAt(0).Name);
        }
コード例 #3
0
        public void GetMemberTypeTest1()
        {
            var c = new CustomAttributesTest();

            Assert.Equal(typeof(string), c.GetType().GetProperty("P1").GetMemberType());
            Assert.Equal(typeof(int), c.GetType().GetProperty("P5").GetMemberType());
            Assert.Equal(typeof(CustomAttributesTest), c.GetType().GetProperty("P6").GetMemberType());
            Assert.Equal(typeof(string), c.GetType().GetField("M1").GetMemberType());
        }
コード例 #4
0
        public void GetMemberTypeTest2()
        {
            var c = new CustomAttributesTest();

            Assert.Throws(typeof(NotSupportedException), () => c.GetType().GetMemberType());
        }
コード例 #5
0
        public void GetCustomAttributes2()
        {
            var c = new CustomAttributesTest();

            Assert.Equal(1, c.GetType().GetProperty("P2").GetCustomAttributes <CustomAttributeAttribute>(false).Length);
        }
コード例 #6
0
        public void GetCustomAttribute2()
        {
            var c = new CustomAttributesTest();

            Assert.NotNull(c.GetType().GetProperty("P2").GetCustomAttribute <CustomAttributeAttribute>(false));
        }