Ejemplo n.º 1
0
        public Boolean save(String file_path, String Password)
        {
            MemoryStream  ms         = new MemoryStream();
            XmlTextWriter textWriter = new XmlTextWriter(ms, new UTF8Encoding(false));

            textWriter.Namespaces  = false;
            textWriter.Indentation = 2;
            textWriter.IndentChar  = '\t';
            textWriter.Formatting  = Formatting.Indented;
            textWriter.WriteStartDocument();
            textWriter.WriteComment("Configuration File");
            textWriter.WriteComment("Original Filename: " + System.IO.Path.GetFileName(file_path));
            textWriter.WriteStartElement("root");
            foreach (DictionaryEntry de in ConfigContainer)
            {
                textWriter.WriteStartElement("item");
                textWriter.WriteAttributeString("name", (String)de.Key);
                textWriter.WriteAttributeString("value", (String)de.Value);
                textWriter.WriteEndElement();
            }
            textWriter.WriteEndElement();
            textWriter.WriteEndDocument();
            textWriter.Close();

            byte[]     b   = ms.GetBuffer();
            string     ste = Crypt.Encrypt(Serialize.UTF8ByteArrayToString(b), Password);
            FileStream fs  = new FileStream(file_path, FileMode.OpenOrCreate, FileAccess.Write);

            byte[] b2 = Serialize.StringToUTF8ByteArray(ste);
            fs.Write(b2, 0, b2.Length);
            fs.Close();
            return(true);
        }
Ejemplo n.º 2
0
        public static Vector3 FromString(String XmlString)
        {
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(Vector3));
            MemoryStream  memoryStream  = new MemoryStream(Serialize.StringToUTF8ByteArray(XmlString));
            XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);

            return((Vector3)xs.Deserialize(memoryStream));
        }