Esempio n. 1
0
        /// <summary>
        ///   Do initialize the methods of the type.
        /// </summary>
        /// <param name="methodInfo">
        ///   A <b>MethodInfo</b> value.
        /// </param>
        private void DoInitMethods(MethodInfo methodInfo)
        {
            // Add attribute assign to this method
            string attributes = Utility.GetAttributesForMember(methodInfo);

            string temName = "Method: " + methodInfo.Name;
            string temText = temName + attributes;
            GCAMethod temMethod = new GCAMethod(temName, temText);
            this.Methods.Add(temMethod);
        }
Esempio n. 2
0
        /// <summary>
        ///   Initialize the properties of the type.
        /// </summary>
        /// <param name="type">
        ///   A <b>Type</b> value.
        /// </param>
        private void InitProperties(Type type)
        {
            // Check parameters.
            if (type == null)
            {
                throw new ArgumentNullException();
            }

            PropertyInfo[] propertyInfos = type.GetProperties(BindingFlags.DeclaredOnly |
                        BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
            foreach (PropertyInfo proInfo in propertyInfos)
            {
                // Get attributes for this property.
                string attributes = Utility.GetAttributesForMember(proInfo);
                string temName = "Property: " + proInfo.Name;
                GCAProperty temPro = new GCAProperty(temName, temName + attributes);

                // Add get method if it exists.
                MethodInfo mGet = proInfo.GetGetMethod();
                if (mGet != null)
                {
                    GCAMethod temMethod = new GCAMethod(mGet.Name);
                    temPro.AccessMethods.Add(temMethod);
                }

                // Add set method if it exists.
                MethodInfo mSet = proInfo.GetSetMethod();
                if (mSet != null)
                {
                    GCAMethod temMethod = new GCAMethod(mSet.Name);
                    temPro.AccessMethods.Add(temMethod);
                }

                this.Property.Add(temPro);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///   Initialize the properties of the type.
        /// </summary>
        /// <param name="type">
        ///   A <b>Type</b> value.
        /// </param>
        private void InitProperties(Type type)
        {
            // Check parameters.
            if (type == null)
            {
                throw new ArgumentNullException();
            }

            PropertyInfo[] propertyInfos = type.GetProperties(BindingFlags.Public |
                        BindingFlags.Instance | BindingFlags.Static);

            //PropertyInfo[] propertyInfos = type.GetProperties(BindingFlags.DeclaredOnly |
            //            BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
            foreach (PropertyInfo proInfo in propertyInfos)
            {
                string temName = null;
                if (proInfo.DeclaringType == type)
                {
                    temName = "Property: " + proInfo.Name;
                }
                else if (proInfo.DeclaringType == typeof(System.Windows.Forms.Control))
                {
                    temName = "Property: From Control " + proInfo.Name;
                }
                else
                {
                    temName = "Property: From Father " + proInfo.Name;
                }
                // Get attributes for this property.
                // string attributes = Utility.GetAttributesForMember(proInfo);
                string types = proInfo.PropertyType.ToString();
                if (proInfo.PropertyType.IsEnum)
                {
                    types = "Enum";
                }

                GCAProperty temPro = new GCAProperty(proInfo.Name, temName + " (" + types + ")");

                //GCAProperty temPro = new GCAProperty(temName, temName + attributes);
                temPro.PropertyType = proInfo.PropertyType;

                // Add get method if it exists.
                MethodInfo mGet = proInfo.GetGetMethod();
                if (mGet != null)
                {
                    GCAMethod temMethod = new GCAMethod(mGet.Name);
                    temPro.AccessMethods.Add(temMethod);
                }

                // Add set method if it exists.
                MethodInfo mSet = proInfo.GetSetMethod();
                if (mSet != null)
                {
                    GCAMethod temMethod = new GCAMethod(mSet.Name);
                    temPro.AccessMethods.Add(temMethod);
                }

                this.Property.Add(temPro);
            }
        }