internal SerializablePlan Clone()
 {
     var clone = new SerializablePlan();
     clone.Name = Name;
     clone.Owner = Owner;
     clone.SortingPreferences = SortingPreferences.Clone();
     clone.Entries.AddRange(Entries.Select(x => x.Clone()));
     clone.InvalidEntries.AddRange(InvalidEntries.Select(x => x.Clone()));
     return clone;
 }
Beispiel #2
0
        internal SerializablePlan Clone()
        {
            var clone = new SerializablePlan();

            clone.Name  = this.Name;
            clone.Owner = this.Owner;
            clone.SortingPreferences = this.SortingPreferences.Clone();
            clone.Entries.AddRange(this.Entries.Select(x => x.Clone()));
            return(clone);
        }
Beispiel #3
0
        /// <summary>
        /// Deserializes a settings file from an old format.
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        private static SerializableSettings DeserializeOldFormat(string filename)
        {
            var oldSerial = Util.DeserializeXML<OldSettings>(filename, Util.LoadXSLT(Properties.Resources.SettingsAndPlanImport));
            var serial = new SerializableSettings();

            // Accounts
            serial.Accounts.AddRange(oldSerial.Accounts);

            // Characters
            foreach (var oldCharacter in oldSerial.Characters)
            {
                // Adds the char both to the characters list and the monitored characters list.
                var character = new SerializableCCPCharacter {
                    ID = oldCharacter.ID, 
                    Name = oldCharacter.Name, 
                    Guid = Guid.NewGuid()
                };
                serial.MonitoredCharacters.Add(new MonitoredCharacterSettings { CharacterGuid = character.Guid });
                serial.Characters.Add(character);
            }

            // Plans
            foreach (var oldPlan in oldSerial.Plans)
            {
                // Look for the owner by his name
                var owner = serial.Characters.SingleOrDefault(x => x.Name == oldPlan.Owner);
                if (owner == null)
                    continue;

                // Imports the plan
                var plan = new SerializablePlan { Owner = owner.Guid, Name = oldPlan.Name };
                plan.Entries.AddRange(oldPlan.Entries);
                serial.Plans.Add(plan);
            }

            return serial;
        }