Example #1
0
        //--------------------------------------
        //  Attributes
        //--------------------------------------

        //--------------------------------------
        //  Properties
        //--------------------------------------

        //--------------------------------------
        //  Methods
        //--------------------------------------

        /// <summary>
        /// Gets the properties.
        /// </summary>
        /// <returns>The properties.</returns>
        /// <param name="obj">Object.</param>
        public static PropertyField[] GetProperties(System.Object obj)
        {
            List <PropertyField> fields = new List <PropertyField>();

            PropertyInfo[] infos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (PropertyInfo info in infos)
            {
                if (!(info.CanRead && info.CanWrite))
                {
                    continue;
                }

                object[] attributes = info.GetCustomAttributes(true);

                bool isExposed = false;

                foreach (object o in attributes)
                {
                    if (o.GetType() == typeof(ExposePropertyAttribute))
                    {
                        isExposed = true;
                        break;
                    }
                }

                if (!isExposed)
                {
                    continue;
                }

                SerializedPropertyType type = SerializedPropertyType.Integer;

                if (PropertyField.GetPropertyType(info, out type))
                {
                    PropertyField field = new PropertyField(obj, info, type);
                    fields.Add(field);
                }
            }

            return(fields.ToArray());
        }