예제 #1
0
 public CInfoChampDynamique(
     string strNomChamp,
     Type typeDonnee,
     string strNomPropriete,
     string strRubrique,
     CInfoStructureDynamique structureValeur)
 {
     m_strNomChamp     = strNomChamp;
     TypeDonnee        = typeDonnee;
     m_strNomPropriete = strNomPropriete;
     StructureValeur   = structureValeur;
     Rubrique          = strRubrique;
 }
예제 #2
0
        ////////////////////////////////////////////
        public static CInfoStructureDynamique GetStructure(Type tp, int nDepth)
        {
            if (GetStructureSurchargee != null)
            {
                CInfoStructureDynamique info = GetStructureSurchargee(tp, nDepth);
                if (info != null)
                {
                    info.m_type = tp;
                }
                return(info);
            }
            if (nDepth < 0)
            {
                return(null);
            }
            object[] attribs = tp.GetCustomAttributes(typeof(DynamicClassAttribute), true);
            CInfoStructureDynamique infoStructure = new CInfoStructureDynamique();

            infoStructure.m_type = tp;
            if (attribs.Length != 0)
            {
                infoStructure.NomConvivial = ((DynamicClassAttribute)attribs[0]).NomConvivial;
            }

            foreach (PropertyInfo property in tp.GetProperties())
            {
                attribs = property.GetCustomAttributes(typeof(DynamicFieldAttribute), true);
                if (attribs.Length > 0)
                {
                    DynamicFieldAttribute fieldAttr = (DynamicFieldAttribute)attribs[0];
                    tp = property.PropertyType;
                    CInfoStructureDynamique infoFils = GetStructure(tp, nDepth - 1);
                    if (infoFils != null && infoFils.Champs.Count == 0)
                    {
                        infoFils = null;
                    }
                    CInfoChampDynamique info = new CInfoChampDynamique(
                        fieldAttr.NomConvivial,
                        tp,
                        property.Name,
                        "",
                        infoFils);
                    infoStructure.Champs.Add(info);
                }
            }
            return(infoStructure);
        }