Beispiel #1
0
        public object DeserializeXmlObject(int cyphermode)
        {
            XmlSerializer sl = new XmlSerializer(typeof(Order));

            using (FileStream fs = new FileStream(Path, FileMode.OpenOrCreate))
            {
                if (cyphermode == 2)
                {
                    object ord = sl.Deserialize(fs);
                    MessageBox.Show("Object successfully deserialized");
                    return(ord);
                }
                else if (cyphermode == 0)
                {
                    DESCrypt des = new DESCrypt();
                    object   ord = des.Deserialize(fs, Path, sl, null);
                    MessageBox.Show("Object successfully deserialized");
                    return(ord);
                }
                else if (cyphermode == 1)
                {
                    AESCrypt aes = new AESCrypt();
                    object   ord = aes.Deserialize(fs, Path, sl, null);
                    MessageBox.Show("Object successfully deserialized");
                    return(ord);
                }
                return(null);
            }
        }
        public object BinaryDeserializeObject(int mode)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            using (FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read))
            {
                if (mode == 2)
                {
                    object obj = formatter.Deserialize(fs);
                    MessageBox.Show("Object successfully deserialized");
                    return(obj);
                }
                else if (mode == 0)
                {
                    DESCrypt des = new DESCrypt();
                    object   ord = des.Deserialize(fs, Path, null, formatter, null);
                    MessageBox.Show("Object successfully deserialized");
                    return(ord);
                }
                else if (mode == 1)
                {
                    AESCrypt aes = new AESCrypt();
                    object   ord = aes.Deserialize(fs, Path, null, formatter, null);
                    MessageBox.Show("Object successfully deserialized");
                    return(ord);
                }
                return(null);
            }
        }
Beispiel #3
0
        public object JsonDeserializeObject(int mode)
        {
            DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(Order));

            using (FileStream fs = new FileStream(_path, FileMode.Open, FileAccess.Read))
            {
                if (mode == 2)
                {
                    object ord = jsonFormatter.ReadObject(fs);
                    MessageBox.Show("Object successfully deserialized");
                    return(ord);
                }
                else if (mode == 0)
                {
                    DESCrypt des = new DESCrypt();
                    object   ord = des.Deserialize(fs, _path, null, null, jsonFormatter);
                    MessageBox.Show("Object successfully deserialized");
                    return(ord);
                }
                else if (mode == 1)
                {
                    AESCrypt aes = new AESCrypt();
                    object   ord = aes.Deserialize(fs, _path, null, null, jsonFormatter);
                    MessageBox.Show("Object successfully deserialized");
                    return(ord);
                }
                return(null);
            }
        }