Esempio n. 1
0
        private static Boolean SetControlValue(Control control, Object value)
        {
            TypeX         tx   = control.GetType();
            String        name = tx.GetCustomAttributeValue <ControlValuePropertyAttribute, String>();
            PropertyInfoX pix  = null;

            if (!String.IsNullOrEmpty(name))
            {
                pix = PropertyInfoX.Create(tx.Type, name);
            }
            if (pix == null)
            {
                pix = PropertyInfoX.Create(tx.Type, "Value");
            }
            if (pix == null)
            {
                pix = PropertyInfoX.Create(tx.Type, "Text");
            }
            if (pix != null)
            {
                if (value == null && pix.Type.IsValueType)
                {
                    return(false);
                }
                pix.SetValue(control, value);
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        static Boolean GetControlValue(ControlBase control, out Object value)
        {
            TypeX         tx   = control.GetType();
            String        name = tx.GetCustomAttributeValue <ControlValuePropertyAttribute, String>();
            PropertyInfoX pix  = null;

            if (!String.IsNullOrEmpty(name))
            {
                pix = PropertyInfoX.Create(tx.BaseType, name);
            }
            if (pix == null)
            {
                pix = PropertyInfoX.Create(tx.BaseType, "Value");
            }
            if (pix == null)
            {
                pix = PropertyInfoX.Create(tx.BaseType, "Text");
            }
            if (pix != null)
            {
                value = pix.GetValue(control);
                return(true);
            }

            value = null;
            return(false);
        }