public void CreateLyric(int?nextToOrder = null) { var maxOrder = OrderUtils.GetMaxOrderNumber(Lyrics.ToArray()); var order = nextToOrder ?? maxOrder; if (order < 0 && order > maxOrder + 1) { throw new ArgumentOutOfRangeException(nameof(order)); } changeHandler?.BeginChange(); // Shifting order that order is larger than current lyric. OrderUtils.ShiftingOrder(Lyrics.Where(x => x.Order > order).ToArray(), 1); // Add new lyric to target order. var createLyric = new Lyric { Text = "New lyric", Order = order + 1, }; beatmap.Add(createLyric); changeHandler?.EndChange(); }
public void TestGetMaxOrderNumber(int[] orders, int number) { var objects = orders.Select(x => new TestOrderObject { Order = x }).ToArray(); var result = OrderUtils.GetMaxOrderNumber(objects); Assert.AreEqual(result, number); }
public void CreateSinger(Singer singer) { singer.Order = OrderUtils.GetMaxOrderNumber(Singers.ToArray()) + 1; Singers.Add(singer); }