コード例 #1
0
        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)));
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
ファイル: DayContainer.cs プロジェクト: uzador/TypiconOnline
        /// <summary>
        /// Возвращает тексты из определенного места в службе
        /// </summary>
        /// <param name="place">Место</param>
        /// <param name="count">Количество</param>
        /// <param name="startFrom">С какого по номеру песнопения начинать выборку</param>
        /// <returns></returns>
        public YmnosStructure GetYmnosStructure(PlaceYmnosSource place, int count, int startFrom)
        {
            ThrowExceptionIfInvalid();

            YmnosStructure stichera = null;

            switch (place)
            {
            //kekragaria
            case PlaceYmnosSource.kekragaria:
                stichera = Esperinos?.Kekragaria?.GetYmnosStructure(count, startFrom);
                break;

            case PlaceYmnosSource.kekragaria_doxastichon:
                if (Esperinos?.Kekragaria?.Doxastichon != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Doxastichon = new YmnosGroup(Esperinos.Kekragaria.Doxastichon)
                    };
                }
                break;

            case PlaceYmnosSource.kekragaria_theotokion:
                if (Esperinos?.Kekragaria?.Theotokion != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Esperinos.Kekragaria.Theotokion
                    };
                }
                break;

            case PlaceYmnosSource.kekragaria_stavrostheotokion:
                if (Esperinos?.Kekragaria?.Theotokion != null &&
                    Esperinos.Kekragaria.Theotokion.Exists(c => c.Kind == YmnosGroupKind.Stavros))
                {
                    //Оставляем только крестобородичен
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Esperinos.Kekragaria.Theotokion
                    };
                    stichera.Theotokion.RemoveAll(c => c.Kind == YmnosGroupKind.Undefined);
                }
                break;

            //liti
            case PlaceYmnosSource.liti:
                stichera = Esperinos?.Liti?.GetYmnosStructure(count, startFrom);
                break;

            case PlaceYmnosSource.liti_doxastichon:
                if (Esperinos?.Liti?.Doxastichon != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Doxastichon = new YmnosGroup(Esperinos.Liti.Doxastichon)
                    };
                }
                break;

            case PlaceYmnosSource.liti_theotokion:
                if (Esperinos?.Liti?.Theotokion != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Esperinos.Liti.Theotokion
                    };
                }
                break;

            //aposticha_esperinos
            case PlaceYmnosSource.aposticha_esperinos:
                stichera = Esperinos?.Aposticha?.GetYmnosStructure(count, startFrom);
                break;

            case PlaceYmnosSource.aposticha_esperinos_doxastichon:
                if (Esperinos?.Aposticha?.Doxastichon != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Doxastichon = new YmnosGroup(Esperinos.Aposticha.Doxastichon)
                    };
                }
                break;

            case PlaceYmnosSource.aposticha_esperinos_theotokion:
                if (Esperinos?.Aposticha?.Theotokion != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Esperinos.Aposticha.Theotokion
                    };
                }
                break;

            //ainoi
            case PlaceYmnosSource.ainoi:
                stichera = Orthros?.Ainoi?.GetYmnosStructure(count, startFrom);
                break;

            case PlaceYmnosSource.ainoi_doxastichon:
                if (Orthros?.Ainoi?.Doxastichon != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Doxastichon = new YmnosGroup(Orthros.Ainoi.Doxastichon)
                    };
                }
                break;

            case PlaceYmnosSource.ainoi_theotokion:
                if (Orthros?.Ainoi?.Theotokion != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Orthros.Ainoi.Theotokion
                    };
                }
                break;

            //aposticha_orthros
            case PlaceYmnosSource.aposticha_orthros:
                stichera = Orthros?.Aposticha?.GetYmnosStructure(count, startFrom);
                break;

            case PlaceYmnosSource.aposticha_orthros_doxastichon:
                if (Orthros?.Aposticha?.Doxastichon != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Doxastichon = new YmnosGroup(Orthros.Aposticha.Doxastichon)
                    };
                }
                break;

            case PlaceYmnosSource.aposticha_orthros_theotokion:
                if (Orthros?.Aposticha?.Theotokion != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Orthros.Aposticha.Theotokion
                    };
                }
                break;

            //troparion
            case PlaceYmnosSource.troparion:
                //Выбираем либо из Малой вечерни, либо с Вечерни тропарь
                YmnosStructure y = (MikrosEsperinos?.Troparion != null) ? MikrosEsperinos.Troparion
                                        : Esperinos.Troparion;

                stichera = new YmnosStructure(y);
                break;

            //sedalen1
            case PlaceYmnosSource.sedalen1:
                stichera = Orthros?.SedalenKathisma1?.GetYmnosStructure(count, startFrom);
                break;

            case PlaceYmnosSource.sedalen1_doxastichon:
                if (Orthros?.SedalenKathisma1?.Doxastichon != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Doxastichon = new YmnosGroup(Orthros.SedalenKathisma1.Doxastichon)
                    };
                }
                break;

            case PlaceYmnosSource.sedalen1_theotokion:
                if (Orthros?.SedalenKathisma1?.Theotokion != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Orthros.SedalenKathisma1.Theotokion
                    };
                }
                break;

            //sedalen2
            case PlaceYmnosSource.sedalen2:
                stichera = Orthros?.SedalenKathisma2?.GetYmnosStructure(count, startFrom);
                break;

            case PlaceYmnosSource.sedalen2_doxastichon:
                if (Orthros?.SedalenKathisma2?.Doxastichon != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Doxastichon = new YmnosGroup(Orthros.SedalenKathisma2.Doxastichon)
                    };
                }
                break;

            case PlaceYmnosSource.sedalen2_theotokion:
                if (Orthros?.SedalenKathisma2?.Theotokion != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Orthros.SedalenKathisma2.Theotokion
                    };
                }
                break;

            //sedalen3
            case PlaceYmnosSource.sedalen3:
                stichera = Orthros?.SedalenKathisma3?.GetYmnosStructure(count, startFrom);
                break;

            case PlaceYmnosSource.sedalen3_doxastichon:
                if (Orthros?.SedalenKathisma3?.Doxastichon != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Doxastichon = new YmnosGroup(Orthros.SedalenKathisma3.Doxastichon)
                    };
                }
                break;

            case PlaceYmnosSource.sedalen3_theotokion:
                if (Orthros?.SedalenKathisma3?.Theotokion != null)
                {
                    stichera = new YmnosStructure()
                    {
                        Theotokion = Orthros.SedalenKathisma3.Theotokion
                    };
                }
                break;
            }

            return(stichera);
        }