Пример #1
0
        public void Load()
        {
            if (File.Exists(settingsFile))
            {
                using (FileStream stream = new FileStream(settingsFile, FileMode.Open))
                {
                    try
                    {
                        // Empty the connection list (should be empty already)
                        mayhem.ConnectionList.Clear();

                        // Load all the serialized connections
                        List <Type> allTypes = new List <Type>();
                        allTypes.AddRange(mayhem.EventList.GetAllTypesInModules());
                        allTypes.AddRange(mayhem.ReactionList.GetAllTypesInModules());
                        mayhem.LoadConnections(ConnectionList.Deserialize(stream, allTypes));

                        Logger.WriteLine("Starting up with " + mayhem.ConnectionList.Count + " connections");
                    }
                    catch (SerializationException e)
                    {
                        ErrorLog.AddError(ErrorType.Failure, "Error loading saved data");
                        Logger.WriteLine("(De-)SerializationException " + e);
                    }
                }
            }

            RunList.ItemsSource = mayhem.ConnectionList;

            Errors = ErrorLog.Errors;
        }