Exemplo n.º 1
0
        /// //////////////////////////////////////////////
        /// <summary>
        /// Sauve un objet de type simple (int, double, string, bool, byte, DateTime ou Type)
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public virtual CResultAErreur TraiteObjetSimple(ref object obj)
        {
            CResultAErreur result = CResultAErreur.True;
            int            nType  = (int)EnumTypeSimple.String;

            if (Mode == ModeSerialisation.Ecriture)
            {
                nType = (int)GetTypeSimpleObjet(obj);
                if (nType == (int)EnumTypeSimple.Inconnu)
                {
                    result.EmpileErreur(I.T("Impossible to serialize non-simple type @1|30111", obj.GetType().ToString()));
                    return(result);
                }
            }
            TraiteInt(ref nType);
            return(TraiteObjetSimple(ref obj, (EnumTypeSimple)nType));
        }
Exemplo n.º 2
0
            //--------------------------------------
            public CResultAErreur ReadStream(StreamReader reader)
            {
                CResultAErreur result = CResultAErreur.True;

                m_tableMessages.Clear();
                try
                {
                    string strLigne = reader.ReadLine();
                    while (strLigne != null)
                    {
                        AddLigne(strLigne);
                        strLigne = reader.ReadLine();
                    }
                }
                catch (Exception e)
                {
                    result.EmpileErreur(new CErreurException(e));
                }
                return(result);
            }
Exemplo n.º 3
0
        /// //////////////////////////////////////////////
        public virtual CResultAErreur TraiteVersion(ref int nVersion)
        {
            CResultAErreur result = CResultAErreur.True;

            switch (Mode)
            {
            case ModeSerialisation.Ecriture:
                TraiteInt(ref nVersion);
                break;

            case ModeSerialisation.Lecture:
                int nVersionEnCours = nVersion;
                TraiteInt(ref nVersion);
                if (nVersion > nVersionEnCours)
                {
                    result.EmpileErreur(I.T("Incorrect version number|30113"));
                }
                break;
            }
            return(result);
        }
Exemplo n.º 4
0
        //--------------------------------------
        public static CResultAErreur ReadFichier(string strAssembly, string strFichier)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                strAssembly = strAssembly.ToUpper(CultureInfo.InvariantCulture);
                StreamReader    reader  = new StreamReader(strFichier);
                CFichierMessage fichier = new CFichierMessage( );
                result = fichier.ReadStream(reader);
                reader.Close();
                if (result)
                {
                    Instance.m_tableFichiers[strAssembly] = fichier;
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
Exemplo n.º 5
0
        //--------------------------------------
        public static CResultAErreur ReadFichier(string strFichier)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                StreamReader    reader        = new StreamReader(strFichier, System.Text.Encoding.Default);
                string          strLigne      = reader.ReadLine();
                string          strLastModule = "";
                CFichierMessage lastModule    = null;
                while (strLigne != null)
                {
                    if (strLigne.Length > 3 && strLigne[0] == '[' && strLigne[strLigne.Length - 1] == ']')
                    {
                        strLastModule = strLigne.Substring(1, strLigne.Length - 2).ToUpper(
                            CultureInfo.CurrentCulture);
                        lastModule = (CFichierMessage)Instance.m_tableFichiers[strLastModule];
                        if (!String.IsNullOrEmpty(strLastModule) && lastModule == null)
                        {
                            lastModule = new CFichierMessage();
                            Instance.m_tableFichiers[strLastModule] = lastModule;
                        }
                    }
                    else
                    if (lastModule != null)
                    {
                        lastModule.AddLigne(strLigne);
                    }
                    strLigne = reader.ReadLine();
                }
                reader.Close();
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
Exemplo n.º 6
0
        //---------------------------------------------------
        /// <summary>
        /// Vérifie qu'il y a le bon nombre de ligne et de colonnes
        /// dans les valeurs, que les colonnes et les lignes sont du bon type./
        /// </summary>
        /// <returns></returns>
        public CResultAErreur VerifieCoherence()
        {
            CResultAErreur result = CResultAErreur.True;

            if (m_lignes.Length == 0)
            {
                result.EmpileErreur(I.T("The array must contain at least a line|30047"));
            }
            if (m_colonnes.Length == 0)
            {
                result.EmpileErreur(I.T("The array must contain at least a column|30048"));
            }
            if (!result)
            {
                return(result);
            }

            if (m_valeurs.Length != m_lignes.Length * m_colonnes.Length)
            {
                result.EmpileErreur(I.T("The value array has an incorrect size|30049"));
            }

            Type      tpLigne      = LignesString?typeof(string):typeof(double);
            Hashtable tableValeurs = new Hashtable();

            foreach (object obj in m_lignes)
            {
                if (!obj.GetType().Equals(tpLigne))
                {
                    result.EmpileErreur(I.T("At least one line header value is incorrect|30050"));
                    break;
                }
                if (tableValeurs[obj] != null)
                {
                    result.EmpileErreur(I.T("At least one line header value is not unique|30051"));
                    break;
                }
                tableValeurs[obj] = true;
            }

            Type tpCol = ColonnesString?typeof(string):typeof(double);

            tableValeurs.Clear();
            foreach (object obj in m_colonnes)
            {
                if (!obj.GetType().Equals(tpCol))
                {
                    result.EmpileErreur(I.T("At least one column header value is incorrect|30052"));
                    break;
                }
                if (tableValeurs[obj] != null)
                {
                    result.EmpileErreur(I.T("At least one column header value is not unique|30053"));
                    break;
                }
                tableValeurs[obj] = true;
            }

            if (LignesString && MethodeResolutionLignes != MethodeResolutionValeurMatrice.ExactOuValeurDefaut)
            {
                result.EmpileErreur(I.T("The line resolution method is not compatible with text lines|30054"));
                return(result);
            }

            if (ColonnesString && MethodeResolutionColonne != MethodeResolutionValeurMatrice.ExactOuValeurDefaut)
            {
                result.EmpileErreur(I.T("The column resolution method is not compatible with text columns|30055"));
                return(result);
            }

            result = VerifieEnteteAvecMethode(Lignes, MethodeResolutionLignes);
            if (!result)
            {
                result.EmpileErreur(I.T("Line header error|30114"));
            }
            result = VerifieEnteteAvecMethode(Colonnes, MethodeResolutionColonne);
            if (!result)
            {
                result.EmpileErreur(I.T("Column header error|30115"));
            }

            return(result);
        }