private static void ValidateProperty(ValueWrapper wrapper, ValidateInputAttribute attribute)
        {
            var validationCallback = ReflectionUtility.GetMethod(wrapper.Target, attribute.CallbackName);

            if (validationCallback == null || validationCallback.ReturnType != typeof(bool) || validationCallback.GetParameters().Length != 1)
            {
                WrongType();
                return;
            }

            var  fieldType     = wrapper.Type;
            Type parameterType = validationCallback.GetParameters()[0].ParameterType;

            if (fieldType != parameterType)
            {
                FieldMismatch();
                return;
            }

            if (!(bool)validationCallback.Invoke(wrapper.Target, new[] { wrapper.GetValue() }))
            {
                if (string.IsNullOrEmpty(attribute.Message))
                {
                    EditorDrawUtility.DrawHelpBox(wrapper.DisplayName + " is not valid", MessageType.Error);
                }
                else
                {
                    EditorDrawUtility.DrawHelpBox(attribute.Message, MessageType.Error);
                }
            }
        }
        private void DrawProperty(ValueWrapper wrapper, DropdownAttribute attribute)
        {
            var target = wrapper.Target;

            //FieldInfo fieldInfo = ReflectionUtility.GetField(target, attribute.name);
            FieldInfo valuesFieldInfo = ReflectionUtility.GetField(target, attribute.ValuesFieldName);

            if (valuesFieldInfo == null)
            {
                FieldNull(wrapper, attribute);
                return;
            }

            if (valuesFieldInfo.GetValue(target) is IList && wrapper.Type == GetElementType(valuesFieldInfo))
            {
                // Selected value
                object selectedValue = wrapper.GetValue();

                // Values and display options
                IList valuesList     = (IList)valuesFieldInfo.GetValue(target);
                var   values         = new object[valuesList.Count];
                var   displayOptions = new string[valuesList.Count];

                for (int i = 0; i < values.Length; i++)
                {
                    object value = valuesList[i];
                    values[i]         = value;
                    displayOptions[i] = value.ToString();
                }

                // Selected value index
                var selectedValueIndex = Array.IndexOf(values, selectedValue);
                if (selectedValueIndex < 0)
                {
                    selectedValueIndex = 0;
                }

                this.DrawDropdown(wrapper, selectedValueIndex, values, displayOptions);
            }

            if (valuesFieldInfo.GetValue(target) is IDropdownList)
            {
                // Current value
                object selectedValue = wrapper.GetValue();

                // Current value index, values and display options
                IDropdownList dropdown = (IDropdownList)valuesFieldInfo.GetValue(target);
                IEnumerator <KeyValuePair <string, object> > dropdownEnumerator = dropdown.GetEnumerator();

                int           index = -1;
                var           selectedValueIndex = -1;
                List <object> values             = new List <object>();
                List <string> displayOptions     = new List <string>();

                while (dropdownEnumerator.MoveNext())
                {
                    index++;

                    KeyValuePair <string, object> current = dropdownEnumerator.Current;
                    if (current.Value.Equals(selectedValue))
                    {
                        selectedValueIndex = index;
                    }

                    values.Add(current.Value);
                    displayOptions.Add(current.Key);
                }

                dropdownEnumerator.Dispose();

                if (selectedValueIndex < 0)
                {
                    selectedValueIndex = 0;
                }

                this.DrawDropdown(wrapper, selectedValueIndex, values.ToArray(), displayOptions.ToArray());
            }

            NotArray(wrapper);
        }