Beispiel #1
0
            public AppOptions Deserialize(XElement item)
            {
                var d = Default;

                Action[] actions =
                {
                    () => d.NavDataLocation          = item.GetString("DatabasePath"),
                    () => d.PromptBeforeExit         = item.GetBool("PromptBeforeExit"),
                    () => d.AutoDLTracks             = item.GetBool("AutoDLTracks"),
                    () => d.AutoDLWind               = item.GetBool("AutoDLWind"),
                    () => d.EnableWindOptimizedRoute =
                        item.GetBool("WindOptimizedRoute"),
                    () => d.HideDctInRoute  = item.GetBool("HideDctInRoute"),
                    () => d.ShowTrackIdOnly = item.GetBool("ShowTrackIdOnly"),
                    () => d.AutoUpdate      = item.GetBool("AutoUpdate"),
                    () => d.ExportCommands  =
                        item.Element("ExportOptions")
                        .Elements("KeyValuePair")
                        .ToDictionary(
                            e => e.GetString("Key"),
                            e => ExportCommand.Deserialize(e.Element("Value")))
                };

                foreach (var a in actions)
                {
                    IgnoreException(a);
                }

                return(d);
            }
Beispiel #2
0
        public void SerializeTest()
        {
            var command      = new ExportCommand(ProviderType.Fsx, @"C:\123", true);
            var elem         = command.Serialize("command1");
            var deserialized = ExportCommand.Deserialize(elem);

            Assert.IsTrue(command.Equals(deserialized));
        }