private static string NettoieProprieteSetValue(string strPropriete) { string strPropFinale = strPropriete; while (true) { int nPos = strPropFinale.LastIndexOf('.'); if (nPos > 0) { string strPropFin = strPropFinale.Substring(nPos + 1); string strCle = ""; string strPropNue = ""; if (!CDefinitionProprieteDynamique.DecomposeNomProprieteUnique(strPropFin, ref strCle, ref strPropNue)) { return(strPropFinale); } Type tp = null; m_tableCleTypeToTypeInterpreteur.TryGetValue(strCle, out tp); if (tp == null) { return(strPropFinale); } IInterpreteurProprieteDynamique interpreteur = Activator.CreateInstance(tp) as IInterpreteurProprieteDynamique; if (interpreteur == null) { return(strPropFin); } if (interpreteur.ShouldIgnoreForSetValue(strPropNue)) { strPropFinale = strPropFinale.Substring(0, nPos); } else { return(strPropFinale); } } else { return(strPropFinale); } } }
//---------------------------------------------------------- /// <summary> /// Le data du result contient la valeur de la propriété pour l'objet /// </summary> /// <param name="objet"></param> /// <param name="strPropriete"></param> /// <returns></returns> public static CResultAErreur GetValue(object objet, string strProprieteComplete, CCacheValeursProprietes cache) { CResultAErreur result = CResultAErreur.True; IApplatisseurProprietes applatisseur = objet as IApplatisseurProprietes; if (applatisseur != null) { objet = applatisseur.GetObjetPourPropriete(strProprieteComplete); } if (cache != null && objet != null) { object valeur = cache.GetValeurCache(objet, strProprieteComplete); if (valeur != null) { result.Data = valeur; return(result); } } string[] strProprietes = strProprieteComplete.Split('.'); string strPropriete = strProprietes[0]; string strSuitePropriete = ""; if (strProprieteComplete.Length > strPropriete.Length) { strSuitePropriete = strProprieteComplete.Substring(strPropriete.Length + 1); } string strCleType = ""; string strProprieteSansCle = ""; if (CDefinitionProprieteDynamique.DecomposeNomProprieteUnique(strPropriete, ref strCleType, ref strProprieteSansCle)) { object objetSource = null; if (cache != null) { objetSource = cache.GetValeurCache(objet, strPropriete); } if (objetSource == null) { strPropriete = strProprieteSansCle; Type tpInterpreteur = null; if (m_tableCleTypeToTypeInterpreteur.TryGetValue(strCleType.ToUpper(), out tpInterpreteur)) { IInterpreteurProprieteDynamique interpreteur = Activator.CreateInstance(tpInterpreteur) as IInterpreteurProprieteDynamique; if (interpreteur != null) { result = interpreteur.GetValue(objet, strPropriete); if (!result) { return(result); } objetSource = result.Data; if (result && cache != null) { cache.StockeValeurEnCache(objet, strProprietes[0], objetSource); } } } else { result.EmpileErreur(I.T("Can not find parser for @1|20001", strPropriete)); return(result); } } if (objetSource != null && strSuitePropriete.Length > 0) { result = GetValue(objetSource, strSuitePropriete); if (result && cache != null) { cache.StockeValeurEnCache(objet, strProprieteComplete, result.Data); } } return(result); } if (m_oldInterpreteur != null) { result.Data = m_oldInterpreteur.GetValue(objet, strProprieteComplete); return(result); } result.EmpileErreur(I.T("Bad property format (@1)|20000", strPropriete)); return(result); }