public bool LoadMapping()
        {
            try
            {
                if (mapping == null)
                {
                    return(false);
                }

                String mappingFilePath = GetMappingFilePath();
                if (!File.Exists(mappingFilePath))
                {
                    return(false);
                }

                Dictionary <String, String> mappingDictionary = DictionarySerializer.Deserialize(mappingFilePath);

                mapping.CopyMappingsFrom(mappingDictionary);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool LoadMapping()
        {
            try
            {
                if (mapping == null)
                {
                    return(false);
                }

                String mappingFilePath = GetMappingFilePath();
                if (!File.Exists(mappingFilePath))
                {
                    return(false);
                }

                InputControls loadedMapping;
                using (TextReader textReader = new StreamReader(mappingFilePath))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(InputControls));
                    loadedMapping = (InputControls)deserializer.Deserialize(textReader);
                    textReader.Close();
                }

                mapping.CopyMappingsFrom(loadedMapping);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }