Beispiel #1
0
 public CookComputing.XmlRpc.XmlRpcStruct toArray(bool withId)
 {
     CookComputing.XmlRpc.XmlRpcStruct temp = new CookComputing.XmlRpc.XmlRpcStruct();
     foreach (string key in Keys)
     {
         if ((key != "id") || (withId))
         {
             if ((this[key] == null))
             {
                 temp.Add(key, false);
             }
             else
             {
                 temp.Add(key, this[key]);
             }
         }
     }
     return(temp);
 }
Beispiel #2
0
        public CookComputing.XmlRpc.XmlRpcStruct toXmlRpc(bool avecLectureSeule)
        {
            object val;
            object dummyObj;

            CookComputing.XmlRpc.XmlRpcStruct retour;
            retour = new CookComputing.XmlRpc.XmlRpcStruct();
            List <System.Reflection.PropertyInfo> listProprietesRel;
            List <System.Reflection.PropertyInfo> listProprietesEnum;

            listProprietesRel  = listeProprieteRelationnelles();
            listProprietesEnum = listeProprieteEnum();
            System.Reflection.FieldInfo libEnum;
            try
            {
                foreach (System.Reflection.PropertyInfo prop in listProprietesRel)
                {
                    val = prop.GetValue(this, null);
                    if (val != null)
                    {
                        dummyObj = null;
                        if (val.GetType() == typeof(models.fields.relations.manyToMany))
                        {
                            dummyObj = ((models.fields.relations.manyToMany)(val)).toXmlRpc();
                        }
                        if (val.GetType() == typeof(models.fields.relations.oneToMany))
                        {
                            dummyObj = ((models.fields.relations.oneToMany)(val)).toXmlRpc();
                        }
                        if (val.GetType() == typeof(models.fields.relations.manyToOne))
                        {
                            dummyObj = ((models.fields.relations.manyToOne)(val)).toXmlRpc();
                        }
                        if (dummyObj != null)
                        {
                            retour.Add(prop.Name, dummyObj);
                        }
                    }
                }
                foreach (System.Reflection.PropertyInfo prop in listProprietesEnum)
                {
                    val = prop.GetValue(this, null);
                    if ((val != null) && (val.ToString() != ""))
                    {
                        if ((val.ToString() != "NULL"))
                        {
                            if ((val.ToString() == "_EMPTY_"))
                            {
                                retour.Add(prop.Name, 0);
                            }
                            else
                            {
                                libEnum = this.GetType().GetField(("_frv_" + prop.Name), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static);
                                retour.Add(prop.Name, ((System.Array)(libEnum.GetValue(this))).GetValue((int)prop.GetValue(this, null)));
                            }
                        }
                    }
                }

                CookComputing.XmlRpc.XmlRpcStruct varStd;
                varStd = _listePropriete.toArray();
                foreach (string key in varStd.Keys)
                {
                    System.Reflection.PropertyInfo prop = this.GetType().GetProperty(key);
                    if (prop != null)
                    {
                        if (avecLectureSeule || prop.CanWrite)
                        {
                            retour.Add(key, varStd[key]);
                        }
                    }
                }
            }
            catch
            {
                throw new Systeme.exceptionOpenERP(IMDEV.OpenERP.Systeme.exceptionOpenERP.ERRORS.ERROR_READING_VALUES);
            }
            return(retour);
        }