private List <DATAPO.DataPO> GetAllInternal(DataPO po) { Type typepo = po.GetType(); PropertyInfo[] properties = typepo.GetProperties(BindingFlags.Public | BindingFlags.Instance); List <DATAPO.DataPO> retour = new List <DataPO>(); foreach (PropertyInfo prp in properties) { // Only work with strings //if (prp.DeclaringType != typeof(DATAPO.DataPO)) { continue; } // If not writable then cannot null it; if not readable then cannot check it's value if (!prp.CanWrite || !prp.CanRead) { continue; } //if(prp.) object objval = null; try { objval = prp.GetValue(po, new object[] { }); } catch (Exception) // fnc a revoir { continue; } if (!(objval is DATAPO.DataPO)) { continue; } DATAPO.DataPO value = objval as DATAPO.DataPO; if (value == null) { continue; } //dict.Add(prp.Name, value); retour.Add(value); } return(retour); }
/// <summary> /// Obtient un Objet (du datarow, fluxxml ou des objets liés) /// méthode principale /// </summary> /// <returns></returns> public object GetData(string nameValue, DataAccessorOptionEnum AccesOptions) { if (this.localRow == null) { return(null); // vraiement innutile, y'a aucune données } try { if (string.IsNullOrWhiteSpace(nameValue)) { return(null); } nameValue = nameValue.Trim(); // ----------------------------- if (nameValue.Contains(":")) // Il s'agit d'un champ provenant d'un autre datapo incorporé { string[] fieldsPO = nameValue.Split(':'); if (fieldsPO.Length < 2 || string.IsNullOrWhiteSpace(fieldsPO[0]) || string.IsNullOrWhiteSpace(fieldsPO[1])) { return(null); } System.Reflection.PropertyInfo pi = this.GetType().GetProperty(fieldsPO[0]); if (pi == null || !pi.CanRead) { return(null); } object ObjfieldIn = pi.GetValue(this, null); if (ObjfieldIn == null) { return(null); } if (ObjfieldIn is DATAPO.DataPO) { DATAPO.DataPO dpo = (DATAPO.DataPO)ObjfieldIn; return(dpo.GetObject(fieldsPO[1], AccesOptions)); } else if (pi.PropertyType.IsClass) { System.Reflection.PropertyInfo subpi = pi.PropertyType.GetProperty(fieldsPO[1]); if (subpi == null) { return(null); } else { return(subpi.GetValue(ObjfieldIn, null)); } // !!! ajouter la recherche dans une liste ou dictionary : 'documents[monchamp="valeur",monchamp2="valeur"]:monchamp3' } } // ----------------------------- else if (nameValue.StartsWith("/")) // Il s'agit du flux de données nosql { //string fieldName = nameValue.Split('/')[1]; // le nom du champ est équivalent au nom du root //IDataPOFlow flow = this.GetFlow(fieldName); //// IDataAccessor flowdata = this.GetFlow(fieldName) as IDataAccessor; // On converti le //if (flow == null ||) return null; //return flow.GetObject(nameValue, AccesOptions); //!!!!!!!!! } // ----------------------------- else // sinon c'est un champdu datarow { System.Data.DataColumn realColumn = DataSetTools.GetColumn(this.localRow.Table, nameValue); if (realColumn != null) { return(this.localRow[realColumn]); } } return(null); } catch (Exception) { return(null); } }