Exemple #1
0
 public CInfoDynamicFieldAjoute(
     CTypeResultatExpression typePropriete,
     GetDynamicValueDelegate getDynamicValue,
     SetDynamicValueDelegate setDynamicValue,
     string strRubrique)
 {
     GetDynamicValue = getDynamicValue;
     SetDynamicValue = setDynamicValue;
     TypePropriete   = typePropriete;
     Rubrique        = strRubrique;
 }
Exemple #2
0
        //---------------------------------------------------
        public static void RegisterDynamicField(
            Type tpSource,
            string strFieldName,
            CTypeResultatExpression typePropriete,
            GetDynamicValueDelegate getDynamicValue,
            SetDynamicValueDelegate setDynamicValue,
            string strRubrique
            )
        {
            Dictionary <string, CInfoDynamicFieldAjoute> dic = null;

            if (!m_dicTypeToFields.TryGetValue(tpSource, out dic))
            {
                dic = new Dictionary <string, CInfoDynamicFieldAjoute>();
                m_dicTypeToFields[tpSource] = dic;
            }
            if (!dic.ContainsKey(strFieldName))
            {
                dic[strFieldName] = new CInfoDynamicFieldAjoute(typePropriete, getDynamicValue, setDynamicValue, strRubrique);
            }
        }
        //------------------------------------------------------------
        public CResultAErreur SetValue(object objet, string strPropriete, object valeur)
        {
            CResultAErreur result = CResultAErreur.True;

            if (objet == null)
            {
                return(result);
            }
            SetDynamicValueDelegate setValue = CGestionnaireProprietesAjoutees.GetSetDelegate(objet.GetType(), strPropriete);

            if (setValue != null)
            {
                try
                {
                    result = setValue(objet, valeur);
                }
                catch (Exception e)
                {
                    result.EmpileErreur(new CErreurException(e));
                }
            }
            return(result);
        }