Exemple #1
0
        public void saveAgents(Agents agenter, string path) // Brugt i Undervisning ved JRT: Construction
        {
            string mypath = @"" + path;

            using (FileStream xmlStream = new FileStream(mypath, FileMode.OpenOrCreate))
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(xmlStream))

                {
                    XmlSerializer serializer = new XmlSerializer(typeof(Agents));

                    serializer.Serialize(xmlWriter, agenter);
                    xmlWriter.Flush();
                    xmlWriter.Close();
                }
            }
        }
Exemple #2
0
        private void LoadAgents()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.ShowDialog();

            if (dlg.FileName != "")
            {
                this.ClearItems();

                Agents agenter = openSave.readAgents(dlg.FileName);

                foreach (var item in agenter)
                {
                    Add(item);
                }
            }
        }
Exemple #3
0
        public Agents readAgents(string path) // Brugt i Undervisning ved JRT: Construction
        {
            string mypath = @"" + path;

            using (FileStream xmlStream = new FileStream(mypath, FileMode.Open))
            {
                using (XmlReader xmlReader = XmlReader.Create(xmlStream))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(Agents));

                    Agents deserializedMembers = serializer.Deserialize(xmlReader) as Agents;

                    agenter = deserializedMembers;

                    xmlReader.Close();

                    return(agenter);
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            agents = (I4GUI.Agents) this.Resources["Agents"];
        }