Exemple #1
0
        static void Main(string[] args)
        {
            var map = new Dictionary <string, string>();

            map.Add("name", "String");
            map.Add("guid", "String");
            map.Add("newProperty", "int");

            string[] text = ReadIn.readIn("Template");
            int      x    = text.Length;

            WriteOut.writeOut(Generate.generateClass(text, "SecondTry", "Person", map, x), "Person");

            Type g = typeof(Generate);

            PropertyInfo[] props = g.GetProperties(BindingFlags.Instance | BindingFlags.Public);

            for (int i = 0; i < props.Length; i++)
            {
                string name = props[i].Name;
                Console.WriteLine("Type: {0}", props[i].PropertyType + ", Name: " + Char.ToLower(name[0]) + name.Substring(1));
            }

            MyAttribute.AttributeDisplay(typeof(Generate));

            Console.WriteLine(Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName);

            Person p = new Person();
        }
Exemple #2
0
        public static void AttributeDisplay(Type classType)
        {
            Console.WriteLine("Methods of class {0}", classType.Name);

            MethodInfo[] methods = classType.GetMethods();

            for (int i = 0; i < methods.Length; i++)
            {
                Object[] attributesArray = methods[i].GetCustomAttributes(true);

                foreach (Attribute item in attributesArray)
                {
                    if (item is MyAttribute)
                    {
                        // Display the fields of the NewAttribute
                        MyAttribute attributeObject = (MyAttribute)item;
                        Console.WriteLine("{0} - {1}, {2} ", methods[i].Name,
                                          attributeObject.someProp, attributeObject.elseProp);
                    }
                }
            }
        }