Ejemplo n.º 1
0
        public static void UpdateRecentExperimentList(string pListLocation, string pExperimentFile)
        {
            RecentExperimentList list = LoadRecentExperimentListFromXML(pListLocation);

            RecentExperimentReference newRef = new RecentExperimentReference(pExperimentFile);

            if (list.Contains(newRef))
            {
                list.Remove(newRef);
            }
            list.Add(newRef);

            SaveRecentExperimentListToXML(list, pListLocation);
        }
Ejemplo n.º 2
0
        public static RecentExperimentList LoadRecentExperimentListFromXML(string pFilepath)
        {
            RecentExperimentList list = new RecentExperimentList();

            if (System.IO.File.Exists(pFilepath))
            {
                try
                {
                    System.Xml.XPath.XPathDocument  doc = new System.Xml.XPath.XPathDocument(pFilepath);
                    System.Xml.XPath.XPathNavigator nav = doc.CreateNavigator();

                    System.Xml.XPath.XPathNodeIterator itemIterator = nav.Select("/RecentExperiments/RecentExperimentItem");
                    int numItems = itemIterator.Count;

                    string fullpath, time;
                    while (itemIterator.MoveNext())
                    {
                        fullpath = itemIterator.Current.GetAttribute("FullPath", String.Empty);
                        time     = itemIterator.Current.GetAttribute("LastAccessTime", String.Empty);

                        RecentExperimentReference item = RecentExperimentReference.CreateRecentExperimentItem(fullpath, time);
                        if (item != null)
                        {
                            list.AddLast(item);
                        }
                    }

                    if (list.Count != numItems)
                    {
                        RecentExperimentsHelper.SaveRecentExperimentListToXML(list, pFilepath);
                    }
                }
                catch (XmlException)
                {
                    System.IO.File.Delete(pFilepath);
                    list.Clear();
                }
            }

            return(list);
        }