Esempio n. 1
0
        /// <summary>
        /// Create a partially deep copy of this train.  The <see cref="TrainTimes"/> property is deep-copied; other properties are shallow-copied.
        /// </summary>
        /// <returns>A copy of the current instance.</returns>
        public Train Copy()
        {
            Train t = new Train
            {
                Headcode              = Headcode,
                LocoDiagram           = LocoDiagram,
                TrainClass            = TrainClass,
                TrainClassId          = TrainClassId,
                IncludeSeparatorAbove = IncludeSeparatorAbove,
                IncludeSeparatorBelow = IncludeSeparatorBelow,
                InlineNote            = InlineNote,
                GraphProperties       = GraphProperties.Copy(),
                ToWork     = ToWork?.Copy(),
                LocoToWork = LocoToWork?.Copy(),
            };

            foreach (TrainLocationTime tlt in TrainTimes)
            {
                t.TrainTimes.Add(tlt.Copy());
            }
            foreach (Note fn in Footnotes as IEnumerable <Note> )
            {
                t.Footnotes.Add(fn);
            }

            return(t);
        }