Пример #1
0
        protected internal virtual object coerceStringToType(string value, Type type)
        {
            PropertyEditor editor = PropertyEditorManager.findEditor(type);

            if (editor == null)
            {
                if ("".Equals(value))
                {
                    return(null);
                }
                throw new ELException(LocalMessages.get("error.coerce.type", typeof(string), type));
            }
            else
            {
                if ("".Equals(value))
                {
                    try
                    {
                        editor.AsText = value;
                    }
                    catch (System.ArgumentException)
                    {
                        return(null);
                    }
                }
                else
                {
                    try
                    {
                        editor.AsText = value;
                    }
                    catch (System.ArgumentException)
                    {
                        throw new ELException(LocalMessages.get("error.coerce.value", value, type));
                    }
                }
                return(editor.Value);
            }
        }