Beispiel #1
0
        public static PropertyField[] GetProperties(object obj)
        {
            var fields = new List <PropertyField>();

            var infos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

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

                var attributes = info.GetCustomAttributes(true);

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

                if (!isExposed)
                {
                    continue;
                }

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

            return(fields.ToArray());
        }
Beispiel #2
0
        public static PropertyField[] GetProperties(object obj)
        {
            var 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(Assets.GameLogic.Utility.ExposePropertyAttribute))
                    {
                        isExposed = true;
                        break;
                    }
                }
                if (!isExposed)
                {
                    continue;
                }

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

            return(fields.ToArray());
        }