示例#1
0
        public static void Load(TextReader reader)
        {
            ItemLocationDictionary sourceInfo = null;

            _allLocations.Clear();
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ItemLocationDictionary));
                sourceInfo = (ItemLocationDictionary)serializer.Deserialize(reader);
                reader.Close();
                _allLocations = sourceInfo;
            }
            catch (Exception) { }
        }
示例#2
0
        public static void Load(string fileName)
        {
            ItemLocationDictionary sourceInfo = null;

            _allLocations.Clear();
            if (File.Exists(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), fileName)))
            {
                try
                {
                    string xml = System.IO.File.ReadAllText(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), fileName));

                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ItemLocationDictionary));
                    System.IO.StringReader reader = new System.IO.StringReader(xml);
                    sourceInfo = (ItemLocationDictionary)serializer.Deserialize(reader);
                    reader.Close();
                    _allLocations = sourceInfo;
                }
                catch (Exception)
                {
                }
            }
        }