/// ////////////////////////////////////////////////////// private void m_btnTester_Click(object sender, System.EventArgs e) { C2iExpression expression = GetExpression(); if (expression == null) { return; } if (m_cmbType.SelectedItem == null || !(m_cmbType.SelectedItem is C2iTypeDonnee)) { CFormAlerte.Afficher(I.T("Select a data type|30026"), EFormAlerteType.Exclamation); return; } TypeDonnee tp = ((C2iTypeDonnee)m_cmbType.SelectedItem).TypeDonnee; object obj = CObjetForTestValeurChampCustom.GetNewForTypeDonnee(tp, null, m_txtTest.Text); CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(obj); CResultAErreur result = expression.Eval(ctx); if (!result) { result.EmpileErreur(I.T("Error during validation formula evaluation|30027")); CFormAlerte.Afficher(result); return; } if ((result.Data is bool && (bool)result.Data) || result.Data.ToString() == "1") { CFormAlerte.Afficher(I.T("Accepted value|30028")); } else { CFormAlerte.Afficher(I.T("Rejected value|30029"), EFormAlerteType.Erreur); } }
/// ////////////////////////////////////////////////////// protected C2iExpression GetExpression() { if (m_cmbType.SelectedItem == null || !(m_cmbType.SelectedItem is C2iTypeDonnee)) { CFormAlerte.Afficher(I.T("Enter a data type|30023"), EFormAlerteType.Exclamation); return(null); } C2iTypeDonnee typeDonnees = (C2iTypeDonnee)m_cmbType.SelectedItem; CContexteAnalyse2iExpression ctx = new CContexteAnalyse2iExpression(new CFournisseurPropDynStd(true), CObjetForTestValeurChampCustom.GetNewForTypeDonnee(typeDonnees.TypeDonnee, null, null).GetType()); CAnalyseurSyntaxique analyseur = new CAnalyseurSyntaxiqueExpression(ctx); CResultAErreur result = analyseur.AnalyseChaine(m_txtFormuleValidation.Text); if (!result) { CFormAlerte.Afficher(result); return(null); } return((C2iExpression)result.Data); }