Ejemplo n.º 1
0
        // Loads a previously saved network topology
        internal static void LoadNetwork()
        {
            // Load the mesh from the file
            XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(formattedMeshNet));
            var           path   = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//netIota.xml";

            System.IO.StreamReader file = new System.IO.StreamReader(path);

            formattedMeshNet readFromFile = (formattedMeshNet)reader.Deserialize(file);

            file.Close();

            meshNet = readFromFile.contents;
        }
Ejemplo n.º 2
0
        // Saves the current network for later use
        internal static void SaveNetwork()
        {
            // Copy the meshNet into the formattedMeshNet object
            formattedMeshNet saveMe = new formattedMeshNet();

            saveMe.contents = meshNet;

            foreach (node n in saveMe.contents)
            {
                n.pathDictionary = new Dictionary <int, int>();
            }

            // Create an XML writer
            XmlSerializer writer = new XmlSerializer(typeof(formattedMeshNet));

            var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//netIota.xml";

            System.IO.FileStream file = System.IO.File.Create(path);

            writer.Serialize(file, saveMe);
            file.Close();
        }