Example #1
0
        static public int Main()
        {
            System.Reflection.MemberInfo info = typeof(Test);
            object[] attributes = info.GetCustomAttributes(false);
            for (int i = 0; i < attributes.Length; i++)
            {
                System.Console.WriteLine(attributes[i]);
            }
            if (attributes.Length != 2)
            {
                return(1);
            }
            MyAttribute attr = (MyAttribute)attributes [0];

            if (attr.val != "testclass")
            {
                return(2);
            }
            return(0);
        }
Example #2
0
        static public int Main()
        {
            System.Reflection.MemberInfo info = typeof(Test);
            object[] attributes = info.GetCustomAttributes(false);
            for (int i = 0; i < attributes.Length; i++)
            {
                System.Console.WriteLine(attributes[i]);
            }
            if (attributes.Length != 1)
            {
                return(1);
            }
            MyAttribute attr = (MyAttribute)attributes [0];

            if (attr.val != "testclass")
            {
                return(2);
            }

            info       = typeof(ITest).GetMethod("get_TestProperty");
            attributes = info.GetCustomAttributes(false);
            for (int i = 0; i < attributes.Length; i++)
            {
                System.Console.WriteLine(attributes[i]);
            }
            if (attributes.Length != 1)
            {
                return(3);
            }

            attr = (MyAttribute)attributes [0];
            if (attr.val != "testifaceproperty")
            {
                return(4);
            }

            return(0);
        }