internal static T GetOptionValueOrUseDefault <T>(IEnumerable attributes, string optionName, T defaultValue)
        {
            object optionValue;

            if (EditorOptionAttribute.TryGetOptionValue(attributes, optionName, out optionValue))
            {
                return((T)optionValue);
            }

            return(defaultValue);
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PropertyEntry propertyEntry = value as PropertyEntry;

            if (null == propertyEntry)
            {
                PropertyValue propertyValue = value as PropertyValue;
                if (null != propertyValue)
                {
                    propertyEntry = propertyValue.ParentProperty;
                }
            }

            ModelPropertyEntry modelPropertyEntry = propertyEntry as ModelPropertyEntry;

            ModelProperty modelProperty = null;

            if (modelPropertyEntry != null)
            {
                modelProperty = modelPropertyEntry.FirstModelProperty;
            }

            if (modelProperty == null)
            {
                return(Binding.DoNothing);
            }

            string optionName = parameter as string;

            if (optionName == null)
            {
                return(Binding.DoNothing);
            }

            object optionValue;

            if (EditorOptionAttribute.TryGetOptionValue(modelProperty.Attributes, optionName, out optionValue))
            {
                return(optionValue);
            }

            return(Binding.DoNothing);
        }