Exemplo n.º 1
0
        //------------------------------------------------------------------------------
        //Le data du result contient la valeur déserializée
        public static CResultAErreur ReadValeur(
            byte[] data,
            IVariableDynamique variable,
            CContexteDonnee contexteDonnee)
        {
            CResultAErreur result = CResultAErreur.True;

            if (data == null)
            {
                return(result);
            }
            MemoryStream           stream     = new MemoryStream(data);
            BinaryReader           reader     = new BinaryReader(stream);
            CSerializerReadBinaire serializer = new CSerializerReadBinaire(reader);
            object valeur = null;

            result = CSerializerValeursVariables.SerializeValeurVariable(
                ref valeur,
                variable,
                serializer,
                contexteDonnee);
            if (result)
            {
                result.Data = valeur;
            }

            reader.Close();
            stream.Close();

            return(result);
        }
Exemplo n.º 2
0
        //------------------------------------------------------------------------------
        //Le data du result contient un byte[] correspondant à la valeur sérializée
        public static CResultAErreur WriteValeur(
            object valeur,
            IVariableDynamique variable,
            CContexteDonnee contexte)
        {
            MemoryStream           stream     = new MemoryStream();
            BinaryWriter           writer     = new BinaryWriter(stream);
            CSerializerSaveBinaire serializer = new CSerializerSaveBinaire(writer);
            CResultAErreur         result     = CSerializerValeursVariables.SerializeValeurVariable(
                ref valeur,
                variable,
                serializer, contexte);

            writer.Close();
            if (result)
            {
                result.Data = stream.ToArray();
            }
            stream.Close();
            return(result);
        }