/// ////////////////////////////////////////// protected override CResultAErreur ProtectedEval(CContexteEvaluationExpression ctx) { CResultAErreur result = CResultAErreur.True; if (!typeof(IEnumerable).IsAssignableFrom(ctx.ObjetSource.GetType())) { result.EmpileErreur(I.T("The function ListInText cannot apply to the @1 type|237", ctx.ObjetSource.GetType().ToString())); return(result); } ArrayList lst = new ArrayList(); foreach (object obj in (IEnumerable)ctx.ObjetSource) { try { ctx.PushObjetSource(obj, true); result = Parametres2i[0].Eval(ctx); ctx.PopObjetSource(true); if (!result) { return(result); } } catch {} } return(result); }
/// ////////////////////////////////////////// protected override CResultAErreur ProtectedEval(CContexteEvaluationExpression ctx) { CResultAErreur result = CResultAErreur.True; if (!typeof(IEnumerable).IsAssignableFrom(ctx.ObjetSource.GetType())) { result.EmpileErreur(I.T("The function ListInText cannot apply to the @1 type|237", ctx.ObjetSource.GetType().ToString())); return(result); } ArrayList lst = new ArrayList(); result = Parametres2i[1].Eval(ctx); if (!result || result.Data == null) { result.EmpileErreur(I.T("Error in separator|236")); return(result); } string strSep = result.Data.ToString(); string strResult = ""; foreach (object obj in (IEnumerable)ctx.ObjetSource) { try { ctx.PushObjetSource(obj, true); result = Parametres2i[0].Eval(ctx); ctx.PopObjetSource(true); if (!result) { return(result); } if (result.Data != null) { string strVal = result.Data.ToString(); if (strVal.Length > 0) { strResult += strVal + strSep; } } } catch {} } if (strResult.Length > 0 && strSep.Length > 0) { strResult = strResult.Substring(0, strResult.Length - strSep.Length); } result.Data = strResult; return(result); }
/// ////////////////////////////////////////// protected override CResultAErreur ProtectedEval(CContexteEvaluationExpression ctx) { CResultAErreur result = CResultAErreur.True; if (!typeof(IEnumerable).IsAssignableFrom(ctx.ObjetSource.GetType())) { result.EmpileErreur(I.T("The function select cannot apply to the @1 type|227", ctx.ObjetSource.GetType().ToString())); return(result); } ArrayList lst = new ArrayList(); List <KeyValuePair <object, object> > lstObjValeurs = new List <KeyValuePair <object, object> >(); foreach (object obj in (IEnumerable)ctx.ObjetSource) { try { ctx.PushObjetSource(obj, true); result = Parametres2i[0].Eval(ctx); ctx.PopObjetSource(true); object val = null; if (result) { val = result.Data; } lstObjValeurs.Add(new KeyValuePair <object, object>(obj, val)); } catch {} } lstObjValeurs.Sort(new CSorterListe()); foreach (KeyValuePair <object, object> kv in lstObjValeurs) { lst.Add(kv.Key); } if (Parametres2i.Length > 1) { result = Parametres2i[1].Eval(ctx); if (result && result.Data is bool && !(bool)result.Data) //descending { lst.Reverse(); } } result.Data = lst; return(result); }
/// ////////////////////////////////////////// protected override CResultAErreur ProtectedEval(CContexteEvaluationExpression ctx) { CResultAErreur result = CResultAErreur.True; if (!typeof(IEnumerable).IsAssignableFrom(ctx.ObjetSource.GetType())) { result.EmpileErreur(I.T("The Calc function cannot apply to the @1 type|244", ctx.ObjetSource.GetType().ToString())); return(result); } ArrayList lst = new ArrayList(); IEnumerable enumerable = null; if (ctx.ObjetSource is IEnumerable) { enumerable = (IEnumerable)ctx.ObjetSource; } else { ArrayList lstTmp = new ArrayList(); lstTmp.Add(ctx.ObjetSource); enumerable = lstTmp; } //Calcule foreach (object obj in (IEnumerable)ctx.ObjetSource) { try { ctx.PushObjetSource(obj, true); result = Parametres2i[0].Eval(ctx); ctx.PopObjetSource(true); if (!result) { return(result); } lst.Add(result.Data); } catch {} } result.Data = lst; return(result); }
/// ////////////////////////////////////////// protected override CResultAErreur ProtectedEval(CContexteEvaluationExpression ctx) { CResultAErreur result = CResultAErreur.True; if (!typeof(IEnumerable).IsAssignableFrom(ctx.ObjetSource.GetType())) { result.EmpileErreur(I.T("The function SelectFirst cannot apply to the @1 type|225", ctx.ObjetSource.GetType().ToString())); return(result); } //Evaluation sur condition int nIndex = 0; object resultat = null; foreach (object obj in (IEnumerable)ctx.ObjetSource) { try { ctx.PushObjetSource(obj, true); result = Parametres2i[0].Eval(ctx); ctx.PopObjetSource(true); if (!result) { return(result); } bool bResult = Convert.ToBoolean(result.Data); if (bResult) { resultat = obj; break; } nIndex++; } catch {} } result.Data = resultat; return(result); }
/// ////////////////////////////////////////// protected override CResultAErreur ProtectedEval(CContexteEvaluationExpression ctx) { CResultAErreur result = CResultAErreur.True; if (!typeof(IEnumerable).IsAssignableFrom(ctx.ObjetSource.GetType())) { result.EmpileErreur(I.T("The function indexs cannot apply to the @1 type|240", ctx.ObjetSource.GetType().ToString())); return(result); } ArrayList lst = new ArrayList(); int nIndex = 0; foreach (object obj in (IEnumerable)ctx.ObjetSource) { try { ctx.PushObjetSource(obj, true); result = Parametres2i[0].Eval(ctx); ctx.PopObjetSource(true); if (!result) { return(result); } bool bResult = Convert.ToBoolean(result.Data); if (bResult) { lst.Add(nIndex); } nIndex++; } catch {} } result.Data = lst; return(result); }
/// ////////////////////////////////////////// protected override CResultAErreur ProtectedEval(CContexteEvaluationExpression ctx) { CResultAErreur result = CResultAErreur.True; if (!typeof(IEnumerable).IsAssignableFrom(ctx.ObjetSource.GetType())) { result.EmpileErreur(I.T("The function select cannot apply to the @1 type|227", ctx.ObjetSource.GetType().ToString())); return(result); } ArrayList lst = new ArrayList(); if (Parametres2i[0].TypeDonnee.TypeDotNetNatif == typeof(int) && Parametres2i[0].TypeDonnee.IsArrayOfTypeNatif) //Evaluation depuis liste { IEnumerable lstSource = (IEnumerable)ctx.ObjetSource; bool bIsIList = typeof(IList).IsAssignableFrom(ctx.ObjetSource.GetType()); ArrayList lstParametres = new ArrayList(); result = EvalParametres(ctx, lstParametres); if (!result) { return(result); } if (!typeof(IEnumerable).IsAssignableFrom(lstParametres[0].GetType())) { result.EmpileErreur(I.T("The function select has incorrect 'list' parameters|228")); return(result); } foreach (object objIndice in (IEnumerable)lstParametres[0]) { try { int nVal = Convert.ToInt32(objIndice); if (bIsIList) { try { lst.Add(((IList)lstSource)[nVal]); } catch { //Indice hors limites } } else { int nPos = 0; foreach (object valeur in lstSource) { if (nPos == nVal) { lst.Add(valeur); break; } nPos++; } } } catch { result.EmpileErreur(I.T("Error in the 'select' list : One of the parameters isn't an integer|229")); return(result); } } } else { //Evaluation sur condition int nIndex = 0; foreach (object obj in (IEnumerable)ctx.ObjetSource) { try { ctx.PushObjetSource(obj, true); result = Parametres2i[0].Eval(ctx); ctx.PopObjetSource(true); if (!result) { return(result); } bool bResult = Convert.ToBoolean(result.Data); if (bResult) { lst.Add(obj); } nIndex++; } catch {} } } result.Data = lst; return(result); }