Exemple #1
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);
            }
        }
Exemple #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.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);
            }
        }