Example #1
0
        public PatternActionResult Invoke(long time, PatternContext context)
        {
            context.SaveTime(time);

            var chordLength = LengthConverter.ConvertFrom(Length, time, context.TempoMap);

            return(new PatternActionResult(time + chordLength,
                                           NoteDefinitions.Select(d => new Note(d.NoteNumber, chordLength, time)
            {
                Channel = context.Channel,
                Velocity = Velocity
            })));
        }
        /// <summary>
        /// This method is to be called after deserialisation.  Where a child object contains both a reference property and a string property containing the ID of the object the reference
        /// property should refer to, this method tries to populate the reference property with the object referred to by the ID property, if possible.
        /// </summary>
        public void ResolveAll()
        {
            Dictionary <string, Location>   map          = LocationList.ToDictionary(l => l.Id);
            Dictionary <string, TrainClass> trainClasses = TrainClassList.ToDictionary(c => c.Id);
            Dictionary <string, Note>       footnotes    = NoteDefinitions.ToDictionary(n => n.Id);

            foreach (var train in TrainList)
            {
                train.ResolveTrainClass(trainClasses);
                train.ResolveFootnotes(footnotes);
                foreach (var time in train.TrainTimes)
                {
                    time.ResolveAll(map, footnotes);
                }
            }
        }