Ejemplo n.º 1
0
        //--------------------------------------
        public CResultAErreur Serialize(C2iSerializer serializer)
        {
            int            nVersion = GetNumVersion();
            CResultAErreur result   = serializer.TraiteVersion(ref nVersion);

            if (!result)
            {
                return(result);
            }
            byte nTmp = (byte)TypeDonnee;

            if (m_valeur == null)
            {
                nTmp = byte.MaxValue;
            }
            serializer.TraiteByte(ref nTmp);
            if (nTmp != byte.MaxValue)
            {
                ETypeChampBasique typeDonnee = (ETypeChampBasique)nTmp;
                switch (typeDonnee)
                {
                case ETypeChampBasique.String:
                    string strVal = StringValue;
                    serializer.TraiteString(ref strVal);
                    StringValue = strVal;
                    break;

                case ETypeChampBasique.Int:
                    int nVal = IntValue == null ? 0 : IntValue.Value;
                    serializer.TraiteInt(ref nVal);
                    IntValue = nVal;

                    break;

                case ETypeChampBasique.Decimal:
                    double fVal = DoubleValue == null ? 0.0 : DoubleValue.Value;
                    serializer.TraiteDouble(ref fVal);
                    DoubleValue = fVal;
                    break;

                case ETypeChampBasique.Date:
                    DateTime dtValue = DateTimeValue == null ? default(DateTime) : DateTimeValue.Value;
                    serializer.TraiteDate(ref dtValue);
                    DateTimeValue = dtValue;
                    break;

                case ETypeChampBasique.Bool:
                    bool bVal = BoolValue == null ? default(bool) : BoolValue.Value;
                    serializer.TraiteBool(ref bVal);
                    BoolValue = bVal;
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static Control GetNewControle(ETypeChampBasique typeChamp)
        {
            Type tp = null;

            m_dicTypeChampToTypeControle.TryGetValue(typeChamp, out tp);
            if (tp != null)
            {
                return((Control)Activator.CreateInstance(tp, new object[0]));
            }
            return(null);
        }
Ejemplo n.º 3
0
        //------------------------------------
        public CResultAErreur Serialize(C2iSerializer serializer)
        {
            int nVersion = GetNumVersion();
            CResultAErreur result = serializer.TraiteVersion(ref nVersion);
            if (!result)
                return result;
            serializer.TraiteString(ref m_strNomChamp);

            int nTmp = (int)m_typeChamp;
            serializer.TraiteInt(ref nTmp);
            m_typeChamp = (ETypeChampBasique)nTmp;

            serializer.TraiteString(ref m_strId);

            serializer.TraiteString(ref m_strDescription);

            return result;
        }
Ejemplo n.º 4
0
        //------------------------------------------
        public CResultAErreur Serialize(C2iSerializer serializer)
        {
            int            nVersion = GetNumVersion();
            CResultAErreur result   = serializer.TraiteVersion(ref nVersion);

            if (!result)
            {
                return(result);
            }
            serializer.TraiteString(ref m_strId);
            serializer.TraiteString(ref m_strNomChamp);
            int nType = (int)m_typeDonnee;

            serializer.TraiteInt(ref nType);
            m_typeDonnee = (ETypeChampBasique)nType;
            if (nVersion >= 1)
            {
                serializer.TraiteBool(ref m_bIsKey);
            }
            return(result);
        }
Ejemplo n.º 5
0
        //----------------------------------------------------
        public static TypeDonnee GetTypeChampCustom(ETypeChampBasique typeBasique)
        {
            switch (typeBasique)
            {
            case ETypeChampBasique.Bool:
                return(TypeDonnee.tBool);

            case ETypeChampBasique.Date:
                return(TypeDonnee.tDate);

            case ETypeChampBasique.Decimal:
                return(TypeDonnee.tDouble);

            case ETypeChampBasique.Int:
                return(TypeDonnee.tEntier);

            case ETypeChampBasique.String:
                return(TypeDonnee.tString);
            }
            return(TypeDonnee.tString);
        }
Ejemplo n.º 6
0
 public static void RegisterControle(ETypeChampBasique typeChamp, Type typeControle)
 {
     m_dicTypeChampToTypeControle[typeChamp] = typeControle;
 }
        /// <summary>
        /// ///////////////////////////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="typeDonnee"></param>
        /// <returns></returns>
        public static object GetNewForTypeDonnee(ETypeChampBasique typeDonnee, object valeur)
        {
            object objTest = null;

            switch (typeDonnee)
            {
            case ETypeChampBasique.Bool:
                if (valeur == null)
                {
                    objTest = new CObjetForTestValeurChampCustomBool( );
                }
                else
                {
                    objTest = new CObjetForTestValeurChampCustomBool((bool)Convert.ChangeType(valeur, typeof(bool), null));
                }
                break;

            case ETypeChampBasique.Date:
                if (valeur == null)
                {
                    objTest = new CObjetForTestValeurChampCustomDateTime( );
                }
                else
                {
                    objTest = new CObjetForTestValeurChampCustomDateTime((DateTime)Convert.ChangeType(valeur, typeof(DateTime), null));
                }
                break;

            case ETypeChampBasique.Decimal:
                if (valeur == null)
                {
                    objTest = new CObjetForTestValeurChampCustomDouble( );
                }
                else
                {
                    objTest = new CObjetForTestValeurChampCustomDouble((double)Convert.ChangeType(valeur, typeof(double), null));
                }
                break;

            case ETypeChampBasique.Int:
                if (valeur == null)
                {
                    objTest = new CObjetForTestValeurChampCustomInt( );
                }
                else
                {
                    objTest = new CObjetForTestValeurChampCustomInt((int)Convert.ChangeType(valeur, typeof(int), null));
                }

                break;

            case ETypeChampBasique.String:
                if (valeur == null)
                {
                    objTest = new CObjetForTestValeurChampCustomString();
                }
                else
                {
                    objTest = new CObjetForTestValeurChampCustomString(valeur.ToString());
                }
                break;
            }
            return(objTest);
        }