/// <summary> /// Возвращает один богослужебный текст с описанием гласа и подобна. /// </summary> /// <param name="index">Сквозной индекс из общего числа текстов данного объекта.</param> /// <returns></returns> public YmnosGroup this[int index] { get { if (index >= YmnosStructureCount || index < 0) { throw new IndexOutOfRangeException("YmnosGroup"); } YmnosGroup ymnosGroup = new YmnosGroup(); int i = index; foreach (YmnosGroup group in Groups) { if (i < group.Ymnis.Count) { //значит ищем в этой коллекции ymnosGroup.Ihos = group.Ihos; ymnosGroup.Annotation = group.Annotation; ymnosGroup.Prosomoion = group.Prosomoion; ymnosGroup.Ymnis.Add(new Ymnos(group.Ymnis[i])); break; } else { i = i - group.Ymnis.Count; } } return(ymnosGroup); } }
public bool Equals(YmnosGroup ymnosGroup) { if (ymnosGroup == null) { throw new ArgumentNullException("YmnosGroup.Equals"); } return(Ihos.Equals(ymnosGroup.Ihos) && Annotation == ymnosGroup.Annotation && Prosomoion == ymnosGroup.Prosomoion); //&& Annotation?.Equals(ymnosGroup.Annotation) == true //&& Prosomoion?.Equals(ymnosGroup.Prosomoion) == true); }
public YmnosGroup(YmnosGroup source) { if (source.Prosomoion != null) { Prosomoion = new Prosomoion(source.Prosomoion); } if (source.Annotation != null) { Annotation = new ItemText(source.Annotation.StringExpression); } Ihos = source.Ihos; source.Ymnis.ForEach(c => Ymnis.Add(new Ymnos(c))); }
public YmnosStructure(YmnosStructure ymnosStructure) { if (ymnosStructure == null) { throw new ArgumentNullException("YmnosStructure"); } ymnosStructure.Groups.ForEach(c => _groups.Add(new YmnosGroup(c))); if (ymnosStructure.Doxastichon != null) { Doxastichon = new YmnosGroup(ymnosStructure.Doxastichon); } ymnosStructure.Theotokion.ForEach(c => _theotokion.Add(new YmnosGroup(c))); }
public YmnosStructure(YmnosGroup group) { _groups.Add(new YmnosGroup(group)); }
/// <summary> /// Возвращает коллекцию богослужебных текстов /// </summary> /// <param name="count">Количество. Если = 0, то выдаем все без фильтрации</param> /// <param name="startFrom">стартовый индекс (1 - ориентированный)</param> /// <returns></returns> public YmnosStructure GetYmnosStructure(int count, int startFrom) { if (count < 0) { throw new ArgumentOutOfRangeException("count"); } if (startFrom < 1 || startFrom > YmnosStructureCount) { throw new ArgumentOutOfRangeException("startFrom"); } ThrowExceptionIfInvalid(); if (count == 0) { //выдаем все без фильтрации YmnosStructure result = new YmnosStructure(); foreach (YmnosGroup group in Groups) { result.Groups.Add(new YmnosGroup(group)); } return(result); } YmnosStructure ymnis = new YmnosStructure(); /*если заявленное количество больше того, что есть, выдаем с повторами * например: 8 = 3 3 2 * 10= 4 4 3 * */ //if (count > YmnosStructureCount) //{ int appendedCount = 0; int i = startFrom - 1; YmnosGroup lastGroup = null; while (appendedCount < count) { //округляем в большую сторону результат деления count на YmnosStructureCount //в результате получаем, сколько раз необходимо повторять песнопение int b = (int)Math.Ceiling((double)(count - appendedCount) / (YmnosStructureCount - i)); YmnosGroup groupToAdd = this[i]; if (lastGroup == null || !lastGroup.Equals(groupToAdd)) { ymnis.Groups.Add(groupToAdd); lastGroup = groupToAdd; appendedCount++; b--; } Ymnos ymnosToAdd = groupToAdd.Ymnis[0]; while (b > 0) { lastGroup.Ymnis.Add(new Ymnos(ymnosToAdd)); b--; appendedCount++; } i++; } //} return(ymnis); }