Ejemplo n.º 1
0
        public VariableValue Get(object obj)
        {
            try
            {
                var value = _field != null
                                        ? _field.GetValue(obj)
                                        : _property.GetValue(obj);

                if (value is IList list)
                {
                    return(VariableValue.Create(ListAdapter.Create(list)));
                }
                else
                {
                    return(VariableValue.CreateAny(value));
                }
            }
            catch
            {
            }

            return(VariableValue.Empty);
        }
Ejemplo n.º 2
0
        public static IVariableList Create(IList list)
        {
            ListAdapter adapter  = null;
            var         itemType = list.GetType().GetGenericArguments()[0];

            if (itemType == typeof(bool))
            {
                adapter = new BoolListAdapter();
            }
            else if (itemType == typeof(int))
            {
                adapter = new IntListAdapter();
            }
            else if (itemType == typeof(float))
            {
                adapter = new FloatListAdapter();
            }
            else if (itemType == typeof(Vector2Int))
            {
                adapter = new Int2ListAdapter();
            }
            else if (itemType == typeof(Vector3Int))
            {
                adapter = new Int3ListAdapter();
            }
            else if (itemType == typeof(RectInt))
            {
                adapter = new IntRectListAdapter();
            }
            else if (itemType == typeof(BoundsInt))
            {
                adapter = new IntBoundsListAdapter();
            }
            else if (itemType == typeof(Vector2))
            {
                adapter = new Vector2ListAdapter();
            }
            else if (itemType == typeof(Vector3))
            {
                adapter = new Vector3ListAdapter();
            }
            else if (itemType == typeof(Vector4))
            {
                adapter = new Vector4ListAdapter();
            }
            else if (itemType == typeof(Quaternion))
            {
                adapter = new QuaternionListAdapter();
            }
            else if (itemType == typeof(RectInt))
            {
                adapter = new RectListAdapter();
            }
            else if (itemType == typeof(BoundsInt))
            {
                adapter = new BoundsListAdapter();
            }
            else if (itemType == typeof(Color))
            {
                adapter = new ColorListAdapter();
            }
            else if (itemType == typeof(string))
            {
                adapter = new StringListAdapter();
            }
            else if (itemType.IsEnum)
            {
                adapter = new EnumListAdapter();
            }
            else
            {
                adapter = new ObjectListAdapter();
            }

            adapter.Setup(list, itemType, true, true, true);

            return(adapter);
        }