Example #1
0
        public static YmnosStructure ToYmnosStructure(this Kontakion kontakion, bool includeIkos = true)
        {
            //конвертируем структуру кондака в YmnosGroup
            YmnosGroup group = new YmnosGroup()
            {
                Annotation = (kontakion.Annotation != null) ? new ItemText(kontakion.Annotation) : null,
                Ihos       = kontakion.Ihos,
                Prosomoion = (kontakion.Prosomoion != null) ? new Prosomoion(kontakion.Prosomoion) : null,
                Ymnis      = new List <Ymnos>()
                {
                    new Ymnos()
                    {
                        Text = kontakion.Ymnos
                    }
                }
            };

            if (includeIkos && kontakion.Ikos != null)
            {
                group.Ymnis.Add(new Ymnos()
                {
                    Text = kontakion.Ikos
                });
            }

            YmnosStructure result = new YmnosStructure();

            result.Groups.Add(group);

            return(result);
        }
        private void SetStringCommonRules(YmnosStructure ymnosStructure, TypiconEntity typicon)
        {
            CommonRuleServiceRequest req = new CommonRuleServiceRequest()
            {
                RuleSerializer = Serializer
            };

            //добавляем стихи к славнику и богородичну
            if (ymnosStructure.Doxastichon != null)
            {
                //слава
                req.Key = CommonRuleConstants.SlavaText;
                ymnosStructure.Doxastichon.Ymnis[0].Stihoi.Add(typicon.GetCommonRuleItemTextValue(req));
                //и ныне
                if (ymnosStructure.Theotokion?.Count > 0)
                {
                    req.Key = CommonRuleConstants.InyneText;
                    ymnosStructure.Theotokion[0].Ymnis[0].Stihoi.Add(typicon.GetCommonRuleItemTextValue(req));
                }
            }
            else
            {
                //слава и ныне
                if (ymnosStructure.Theotokion?.Count > 0)
                {
                    req.Key = CommonRuleConstants.SlavaInyneText;
                    ymnosStructure.Theotokion[0].Ymnis[0].Stihoi.Add(typicon.GetCommonRuleItemTextValue(req));
                }
            }
        }
        public YmnosStructure GetStructure(RuleHandlerSettings settings)
        {
            if (!IsValid)
            {
                return(null);
            }

            YmnosStructure result = new YmnosStructure();

            switch (Kind)
            {
            case YmnosRuleKind.Ymnos:
                result.Groups.Add(Element);
                break;

            case YmnosRuleKind.Doxastichon:
                result.Doxastichon = Element;
                break;

            case YmnosRuleKind.Theotokion:
                result.Theotokion.Add(Element);
                break;
            }

            return(result);
        }
        private void SetStringCommonRules(YmnosStructure ymnosStructure, int typiconId)
        {
            //добавляем стихи к славнику и богородичну
            if (ymnosStructure.Doxastichon != null)
            {
                //слава
                AddPredefinedStihos(ymnosStructure.Doxastichon.Ymnis[0].Stihoi, CommonRuleConstants.SlavaText);

                //и ныне
                if (ymnosStructure.Theotokion?.Count > 0)
                {
                    AddPredefinedStihos(ymnosStructure.Theotokion[0].Ymnis[0].Stihoi, CommonRuleConstants.InyneText);
                }
            }
            //слава и ныне
            else if (ymnosStructure.Theotokion?.Count > 0)
            {
                AddPredefinedStihos(ymnosStructure.Theotokion[0].Ymnis[0].Stihoi, CommonRuleConstants.SlavaInyneText);
            }

            void AddPredefinedStihos(ICollection <ItemText> stihoi, string key)
            {
                var itemText = Serializer.GetCommonRuleItemTextValue(typiconId, key);

                stihoi.Add(itemText);
            }
        }
Example #5
0
        public override DayElementBase Calculate(RuleHandlerSettings settings)
        {
            YmnosStructure result = null;

            Kanonas kanonas = GetKanonas(settings);

            if (kanonas != null)
            {
                switch (Place)
                {
                case KanonasPlaceKind.sedalen:
                    if (kanonas.Sedalen != null)
                    {
                        result = new YmnosStructure();
                        result.Groups.AddRange(kanonas.Sedalen.Groups);
                    }
                    break;

                case KanonasPlaceKind.kontakion:
                    if (kanonas.Kontakion != null)
                    {
                        result = kanonas.Kontakion.ToYmnosStructure();
                    }
                    break;
                }
            }

            return(result);
        }
Example #6
0
        public override DayElementBase Calculate(RuleHandlerSettings settings)
        {
            YmnosStructure result = null;

            if (!IsValid)
            {
                return(null);
            }

            if (Source == YmnosSource.Irmologion)
            {
                int calcIhos = (ReferenceYmnos.Calculate(settings) as YmnosStructure).Ihos;

                GetTheotokionResponse response = theotokionApp.Get(
                    new GetTheotokionRequest()
                {
                    Place = Place.Value, Ihos = calcIhos, DayOfWeek = settings.Date.DayOfWeek
                });

                if (response.Exception == null && response.BookElement != null)
                {
                    result = new YmnosStructure();
                    result.Theotokion.Add(response.BookElement);
                }
            }
            else
            {
                result = base.Calculate(settings) as YmnosStructure;
            }

            return(result);
        }
Example #7
0
        public override DayElementBase Calculate(RuleHandlerSettings settings)
        {
            YmnosStructure result = null;

            Kanonas kanonas = GetKanonas(settings);

            if (kanonas != null)
            {
                switch (Place)
                {
                case KanonasPlaceKind.sedalen:
                    if (kanonas.Sedalen?.Groups?.Count > 0 &&
                        kanonas.Sedalen?.Groups[0]?.Ymnis?.Count > 0)
                    {
                        result = new YmnosStructure();
                        YmnosGroup th = new YmnosGroup()
                        {
                            Annotation = new ItemText(kanonas.Sedalen.Groups[0].Annotation),
                            Ihos       = kanonas.Sedalen.Groups[0].Ihos,
                            Prosomoion = new Prosomoion(kanonas.Sedalen.Groups[0].Prosomoion)
                        };
                        th.Ymnis.Add(new Ymnos(kanonas.Sedalen.Groups[0].Ymnis[0]));
                        result.Theotokion.Add(th);
                    }
                    break;

                case KanonasPlaceKind.sedalen_theotokion:
                    if (kanonas.Sedalen?.Theotokion != null)
                    {
                        result = new YmnosStructure()
                        {
                            Theotokion = kanonas.Sedalen.Theotokion
                        };
                    }
                    break;

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

                default:
                    result = base.Calculate(settings) as YmnosStructure;
                    break;
                }
            }

            return(result);
        }
 private void AsKanonasSedalenRule(KSedalenRule r, YmnosStructure s)
 {
     if (r is KSedalenTheotokionRule)
     {
         Structure.Theotokion = s.Theotokion;
     }
     else
     {
         Structure.Groups.AddRange(s.Groups);
     }
 }
Example #9
0
        public override DayElementBase Calculate(RuleHandlerSettings settings)
        {
            YmnosStructure result = null;

            if (base.Calculate(settings) is Kontakion kontakion)
            {
                result = kontakion.ToYmnosStructure(ShowIkos);
            }

            return(result);
        }
Example #10
0
        /// <summary>
        /// Возвращает указанные в правиле богослужебные тексты.
        /// </summary>
        /// <param name="settings"></param>
        /// <returns>Если таковые не объявлены в DayWorship, возвращает NULL.</returns>
        public YmnosStructure GetStructure(RuleHandlerSettings settings)
        {
            YmnosStructure result = null;

            if (!ThrowExceptionIfInvalid(settings))
            {
                //разбираемся с source
                DayContainer day = GetDayContainer(settings);

                //не выдаем ошибки, если день не найден
                if (day != null)
                {
                    //теперь разбираемся с place И kind
                    switch (Kind)
                    {
                    case YmnosRuleKind.Ymnos:
                    {
                        var groups = day.GetYmnosGroups(Place, Count, StartFrom);
                        if (groups != null)
                        {
                            result = new YmnosStructure();
                            result.Groups.AddRange(groups);
                        }
                    }
                    break;

                    case YmnosRuleKind.Doxastichon:
                    {
                        var groups = day.GetYmnosGroups(Place, 1, StartFrom);
                        if (groups?.Count > 0)
                        {
                            result = new YmnosStructure {
                                Doxastichon = groups[0]
                            };
                        }
                    }
                    break;

                    case YmnosRuleKind.Theotokion:
                    {
                        var groups = day.GetYmnosGroups(Place, 1, StartFrom);
                        if (groups?.Count > 0)
                        {
                            result = new YmnosStructure();
                            result.Theotokion.AddRange(groups);
                        }
                    }
                    break;
                    }
                }
            }

            return(result);
        }
        private void AppendKontakion(CreateViewModelRequest <KontakionRule> req, YmnosStructure kontakion, ViewModelItem view)
        {
            var viewModel = new ElementViewModel()
            {
                view
            };

            var group = kontakion.Groups[0];

            group.Annotation.AppendViewModel(req.Handler, viewModel);
            group.Prosomoion.AppendViewModel(req.Handler, Serializer, viewModel);
            group.Ymnis[0].Text.AppendViewModel(req.Handler, viewModel);

            req.AppendModelAction(viewModel);
        }
        private void AsYmnosRule(YmnosRule r, YmnosStructure s)
        {
            switch (r.Kind)
            {
            case YmnosRuleKind.YmnosRule:
                Structure.Groups.AddRange(s.Groups);
                break;

            case YmnosRuleKind.DoxastichonRule:
                Structure.Doxastichon = s.Doxastichon;
                break;

            case YmnosRuleKind.TheotokionRule:
                Structure.Theotokion = s.Theotokion;
                break;
            }
        }
Example #13
0
        public void YmnosSrtucture_Deserialization()
        {
            string xmlString = @"<YmnosStructure>
			                        <group ihos=""1"">
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, 1 стихира </item>
					                        </text>
				                        </ymnos>
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, 2 стихира </item>
					                        </text>
				                        </ymnos>
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, 3 стихира </item>
					                        </text>
				                        </ymnos>
			                        </group>
			                        <doxastichon ihos=""8"">
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, Славник</item>
					                        </text>
				                        </ymnos>
			                        </doxastichon>
			                        <theotokion ihos=""8"" kind=""stavros"">
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, Крестобогородичен</item>
					                        </text>
				                        </ymnos>
			                        </theotokion>
		                        </YmnosStructure>"        ;

            TypiconSerializer ser     = new TypiconSerializer();
            YmnosStructure    element = ser.Deserialize <YmnosStructure>(xmlString);

            Assert.AreEqual(element.Groups.Count, 1);
            Assert.AreEqual(element.Groups[0].Ymnis.Count, 3);
            Assert.IsNotNull(element.Doxastichon);
            Assert.AreEqual(element.Doxastichon.Ihos, 8);
            Assert.AreEqual(element.Theotokion[0].Kind, YmnosGroupKind.Stavros);
        }
Example #14
0
        public void YmnosSrtucture_Serialization()
        {
            string xmlString = @"<YmnosStructure>
			                        <group ihos=""1"">
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, 1 стихира </item>
					                        </text>
				                        </ymnos>
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, 2 стихира </item>
					                        </text>
				                        </ymnos>
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, 3 стихира </item>
					                        </text>
				                        </ymnos>
			                        </group>
			                        <doxastichon ihos=""8"">
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, Славник</item>
					                        </text>
				                        </ymnos>
			                        </doxastichon>
			                        <theotokion ihos=""8"" kind=""stavros"">
				                        <ymnos>
					                        <text>
						                        <item language=""cs-ru"">[item] [sign] Господи воззвах, Крестобогородичен</item>
					                        </text>
				                        </ymnos>
			                        </theotokion>
		                        </YmnosStructure>"        ;

            TypiconSerializer ser     = new TypiconSerializer();
            YmnosStructure    element = ser.Deserialize <YmnosStructure>(xmlString);

            string result = ser.Serialize(element);

            Assert.Pass(result);
        }
        /// <summary>
        /// Производит слияние двух Структур песнопений. Славник и Богородичен переписывается
        /// </summary>
        /// <param name="structure"></param>
        /// <param name="source"></param>
        public static void Merge(this YmnosStructure structure, YmnosStructure source)
        {
            if (structure == null || source == null)
            {
                return;
            }

            structure.Groups.AddRange(source.Groups);

            if (source.Doxastichon != null)
            {
                structure.Doxastichon = source.Doxastichon;
            }

            if (source.Theotokion?.Count > 0)
            {
                structure.Theotokion = source.Theotokion;
            }
        }
        private void CalculateYmnosStructure(RuleHandlerSettings settings, ExecContainer container)
        {
            Structure = new YmnosStructure();
            foreach (ICalcStructureElement element in container.ChildElements)
            {
                if (element.Calculate(settings) is YmnosStructure s)
                {
                    switch (element)
                    {
                    case YmnosRule r:
                        AsYmnosRule(r, s);
                        break;

                    case KSedalenRule r:
                        AsKanonasSedalenRule(r, s);
                        break;
                    }
                }
            }
        }
        public override void Create(CreateViewModelRequest <YmnosStructureRule> req)
        {
            if (req.Element == null ||
                req.Element.Structure == null)
            {
                //TODO: просто ничего не делаем, хотя надо бы это обрабатывать
                return;
            }

            ElementViewModel viewModel = new ElementViewModel();

            //здесь вставляется индивидуальная обработка наследников
            AppendCustomForm(req /*, viewModel*/);

            //а теперь добавляем стихиры, общие для всех наследников данного класса
            YmnosStructure ymnosStructure = req.Element.Structure;

            //Groups
            foreach (var group in ymnosStructure.Groups)
            {
                viewModel.AddRange(group.GetViewModel(req.Handler, Serializer));
            }

            SetStringCommonRules(ymnosStructure, req.Handler.Settings.Rule.Owner);

            //Doxastichon
            if (ymnosStructure.Doxastichon != null)
            {
                viewModel.AddRange(ymnosStructure.Doxastichon.GetViewModel(req.Handler, Serializer));
            }
            //Theotokion
            if (ymnosStructure.Theotokion?.Count > 0)
            {
                viewModel.AddRange(ymnosStructure.Theotokion[0].GetViewModel(req.Handler, Serializer));
            }

            req.AppendModelAction(viewModel);
        }
        protected override void FillChildElements()
        {
            //здесь вставляется индивидуальная обработка наследников
            ConstructForm(_handler);

            //а теперь добавляем стихиры, общие для всех наследников данного класса
            YmnosStructure ymnosStructure = _rule.Structure;

            //Groups
            for (int i = 0; i < ymnosStructure.Groups.Count; i++)
            {
                YmnosGroup group = ymnosStructure.Groups[i];

                YmnosGroupViewModel item = new YmnosGroupViewModel(group, _handler, Serializer);

                if (i == 0)
                {
                    Ihos     = group.Ihos;
                    IhosText = item.IhosText;
                }

                _childElements.AddRange(item.ChildElements);
            }

            SetStringCommonRules(ymnosStructure);

            //Doxastichon
            if (ymnosStructure.Doxastichon != null)
            {
                _childElements.AddRange(new YmnosGroupViewModel(ymnosStructure.Doxastichon, _handler, Serializer).ChildElements);
            }
            //Theotokion
            if (ymnosStructure.Theotokion?.Count > 0)
            {
                _childElements.AddRange(new YmnosGroupViewModel(ymnosStructure.Theotokion[0], _handler, Serializer).ChildElements);
            }
        }
Example #19
0
        /// <summary>
        /// Возвращает тексты из определенного места в службе
        /// </summary>
        /// <param name="place">Место</param>
        /// <param name="count">Количество</param>
        /// <param name="startFrom">С какого по номеру песнопения начинать выборку</param>
        /// <returns></returns>
        public static YmnosGroupCollection GetYmnosGroups(this DayContainer container, PlaceYmnosSource place, int count, int startFrom)
        {
            container.ThrowExceptionIfInvalid();

            YmnosGroupCollection result = default(YmnosGroupCollection);

            switch (place)
            {
            //kekragaria
            case PlaceYmnosSource.kekragaria:
                result = container.Esperinos?.Kekragaria?.Groups.GetYmnis(count, startFrom);
                break;

            case PlaceYmnosSource.kekragaria_doxastichon:
            {
                result = GetDoxastichon(container.Esperinos?.Kekragaria);
            }
            break;

            case PlaceYmnosSource.kekragaria_theotokion:
            {
                result = GetTheotokion(container.Esperinos?.Kekragaria);
            }
            break;

            case PlaceYmnosSource.kekragaria_stavrostheotokion:
            {
                result = GetTheotokion(container.Esperinos?.Kekragaria, YmnosGroupKind.Stavros);
            }
            break;

            //liti
            case PlaceYmnosSource.liti:
                result = container.Esperinos?.Liti?.Groups.GetYmnis(count, startFrom);
                break;

            case PlaceYmnosSource.liti_doxastichon:
            {
                result = GetDoxastichon(container.Esperinos?.Liti);
            }
            break;

            case PlaceYmnosSource.liti_theotokion:
            {
                result = GetTheotokion(container.Esperinos?.Liti);
            }
            break;

            //aposticha_esperinos
            case PlaceYmnosSource.aposticha_esperinos:
                result = container.Esperinos?.Aposticha?.Groups.GetYmnis(count, startFrom);
                break;

            case PlaceYmnosSource.aposticha_esperinos_doxastichon:
            {
                result = GetDoxastichon(container.Esperinos?.Aposticha);
            }
            break;

            case PlaceYmnosSource.aposticha_esperinos_theotokion:
            {
                result = GetTheotokion(container.Esperinos?.Aposticha);
            }
            break;

            //ainoi
            case PlaceYmnosSource.ainoi:
                result = container.Orthros?.Ainoi?.Groups.GetYmnis(count, startFrom);
                break;

            case PlaceYmnosSource.ainoi_doxastichon:
            {
                result = GetDoxastichon(container.Orthros?.Ainoi);
            }
            break;

            case PlaceYmnosSource.ainoi_theotokion:
            {
                result = GetTheotokion(container.Orthros?.Ainoi);
            }
            break;

            //aposticha_orthros
            case PlaceYmnosSource.aposticha_orthros:
                result = container.Orthros?.Aposticha?.Groups.GetYmnis(count, startFrom);
                break;

            case PlaceYmnosSource.aposticha_orthros_doxastichon:
            {
                result = GetDoxastichon(container.Orthros?.Aposticha);
            }
            break;

            case PlaceYmnosSource.aposticha_orthros_theotokion:
            {
                result = GetTheotokion(container.Orthros?.Aposticha);
            }
            break;

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

                result = y?.Groups.GetYmnis(count, startFrom);
            }
            break;

            case PlaceYmnosSource.troparion_doxastichon:
            {
                result = GetDoxastichon(container.MikrosEsperinos?.Troparion ?? container.Esperinos?.Troparion);
            }
            break;

            case PlaceYmnosSource.troparion_theotokion:
            {
                result = GetTheotokion(container.MikrosEsperinos?.Troparion ?? container.Esperinos?.Troparion);
            }
            break;

            //sedalen1
            case PlaceYmnosSource.sedalen1:
            {
                result = container.Orthros?.SedalenKathisma1?.Groups.GetYmnis(count, startFrom);
            }
            break;

            case PlaceYmnosSource.sedalen1_doxastichon:
            {
                result = GetDoxastichon(container.Orthros?.SedalenKathisma1);
            }
            break;

            case PlaceYmnosSource.sedalen1_theotokion:
            {
                result = GetTheotokion(container.Orthros?.SedalenKathisma1);
            }
            break;

            //sedalen2
            case PlaceYmnosSource.sedalen2:
            {
                result = container.Orthros?.SedalenKathisma2?.Groups.GetYmnis(count, startFrom);
            }
            break;

            case PlaceYmnosSource.sedalen2_doxastichon:
            {
                result = GetDoxastichon(container.Orthros?.SedalenKathisma2);
            }
            break;

            case PlaceYmnosSource.sedalen2_theotokion:
            {
                result = GetTheotokion(container.Orthros?.SedalenKathisma2);
            }
            break;

            //sedalen3
            case PlaceYmnosSource.sedalen3:
            {
                result = container.Orthros?.SedalenKathisma3?.Groups.GetYmnis(count, startFrom);
            }
            break;

            case PlaceYmnosSource.sedalen3_doxastichon:
            {
                result = GetDoxastichon(container.Orthros?.SedalenKathisma3);
            }
            break;

            case PlaceYmnosSource.sedalen3_theotokion:
            {
                result = GetTheotokion(container.Orthros?.SedalenKathisma3);
            }
            break;

            //sedalen_kanonas
            case PlaceYmnosSource.sedalen_kanonas:
            {
                result = container.Orthros?.SedalenKanonas?.Groups.GetYmnis(count, startFrom);
            }
            break;

            case PlaceYmnosSource.sedalen_kanonas_theotokion:
            {
                result = GetTheotokion(container.Orthros?.SedalenKanonas);
            }
            break;

            case PlaceYmnosSource.sedalen_kanonas_stavrostheotokion:
            {
                result = GetTheotokion(container.Orthros?.SedalenKanonas, YmnosGroupKind.Stavros);
            }
            break;
            }

            return(result);

            YmnosGroupCollection GetDoxastichon(YmnosStructure structure)
            {
                var found = structure?.Doxastichon?.GetGroupWithSingleYmnos(0);

                return((structure?.Doxastichon is YmnosGroup d) ? new YmnosGroupCollection()
                {
                    new YmnosGroup(d)
                } : default(YmnosGroupCollection));
            }

            YmnosGroupCollection GetTheotokion(YmnosStructure structure, YmnosGroupKind kind = YmnosGroupKind.Undefined)
            {
                var found = structure?.Theotokion?.FirstOrDefault(c => c.Kind == kind)?.GetGroupWithSingleYmnos(0);

                return((found != null) ? new YmnosGroupCollection()
                {
                    found
                } : default(YmnosGroupCollection));
            }
        }
        private (ViewModelItem Kontakion, ViewModelItem Ikos) GetHeaders(CreateViewModelRequest <KontakionRule> req, YmnosStructure kontakion)
        {
            List <TextHolder> headers = req.Handler.Settings.Rule.Owner.GetCommonRuleChildren(
                new CommonRuleServiceRequest()
            {
                Key = CommonRuleConstants.Kontakion, RuleSerializer = Serializer
            }).Cast <TextHolder>().ToList();

            var viewKontakion = ViewModelItemFactory.Create(headers[0], req.Handler, Serializer);

            viewKontakion.Paragraphs[0].Replace(IHOS_STRING,
                                                req.Handler.Settings.Language.IntConverter.ToString(kontakion.Ihos));

            var viewIkos = ViewModelItemFactory.Create(headers[1], req.Handler, Serializer);

            return(viewKontakion, viewIkos);
        }
Example #21
0
        /// <summary>
        /// Возвращает указанные в правиле богослужебные тексты.
        /// </summary>
        /// <param name="date"></param>
        /// <param name="handler"></param>
        /// <returns>Если таковые не объявлены в DayService, возвращает NULL.</returns>
        public virtual DayElementBase Calculate(RuleHandlerSettings settings)
        {
            if (!IsValid)
            {
                return(null);
            }

            YmnosStructure result = null;

            //разбираемся с source
            DayStructureBase dayWorship = null;

            switch (Source)
            {
            case YmnosSource.Item1:
                dayWorship = (settings.DayWorships.Count > 0) ? settings.DayWorships[0] : null;
                break;

            case YmnosSource.Item2:
                dayWorship = (settings.DayWorships.Count > 1) ? settings.DayWorships[1] : null;
                break;

            case YmnosSource.Item3:
                dayWorship = (settings.DayWorships.Count > 2) ? settings.DayWorships[2] : null;
                break;

            case YmnosSource.Oktoikh:
                dayWorship = settings.OktoikhDay;
                break;
            }

            //if (dayWorship == null)
            //{
            //    throw new KeyNotFoundException("YmnosStructureRule source not found: " + Source.ToString());
            //}

            //не выдаем ошибки, если день не найден
            if (dayWorship != null)
            {
                //теперь разбираемся с place И kind

                YmnosGroup        group  = null;
                List <YmnosGroup> groups = null;

                switch (Kind)
                {
                case YmnosRuleKind.YmnosRule:
                    groups = dayWorship.GetElement().GetYmnosStructure(Place.Value, Count, StartFrom)?.Groups;
                    if (groups != null)
                    {
                        result = new YmnosStructure();
                        result.Groups.AddRange(groups);
                    }

                    break;

                case YmnosRuleKind.DoxastichonRule:
                    group = dayWorship.GetElement().GetYmnosStructure(Place.Value, Count, StartFrom)?.Doxastichon;
                    if (group != null)
                    {
                        result = new YmnosStructure
                        {
                            Doxastichon = group
                        };
                    }

                    break;

                case YmnosRuleKind.TheotokionRule:
                    groups = dayWorship.GetElement().GetYmnosStructure(Place.Value, Count, StartFrom)?.Theotokion;
                    if (groups != null)
                    {
                        result = new YmnosStructure();
                        result.Theotokion.AddRange(groups);
                    }

                    break;
                }
            }

            return(result);
        }
        /// <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)
        {
            YmnosStructure stichera = null;

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

            case PlaceYmnosSource.kekragaria_doxastichon:
                stichera = new YmnosStructure()
                {
                    Doxastichon = new YmnosGroup(_dayContainer.Esperinos.Kekragaria.Doxastichon)
                };
                break;

            case PlaceYmnosSource.kekragaria_theotokion:
                //TODO: прамая ссылка без копирования и клонирования
                stichera = new YmnosStructure()
                {
                    Theotokion = _dayContainer.Esperinos.Kekragaria.Theotokion
                };
                break;

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

            case PlaceYmnosSource.liti_doxastichon:
                stichera = new YmnosStructure()
                {
                    Doxastichon = new YmnosGroup(_dayContainer.Esperinos.Liti.Doxastichon)
                };
                break;

            case PlaceYmnosSource.liti_theotokion:
                //TODO: прамая ссылка без копирования и клонирования
                stichera = new YmnosStructure()
                {
                    Theotokion = _dayContainer.Esperinos.Liti.Theotokion
                };
                break;

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

            case PlaceYmnosSource.aposticha_esperinos_doxastichon:
                stichera = new YmnosStructure()
                {
                    Doxastichon = new YmnosGroup(_dayContainer.Esperinos.Aposticha.Doxastichon)
                };
                break;

            case PlaceYmnosSource.aposticha_esperinos_theotokion:
                //TODO: прамая ссылка без копирования и клонирования
                stichera = new YmnosStructure()
                {
                    Theotokion = _dayContainer.Esperinos.Aposticha.Theotokion
                };
                break;

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

            case PlaceYmnosSource.ainoi_doxastichon:
                stichera = new YmnosStructure()
                {
                    Doxastichon = new YmnosGroup(_dayContainer.Orthros.Ainoi.Doxastichon)
                };
                break;

            case PlaceYmnosSource.ainoi_theotokion:
                //TODO: прамая ссылка без копирования и клонирования
                stichera = new YmnosStructure()
                {
                    Theotokion = _dayContainer.Orthros.Ainoi.Theotokion
                };
                break;

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

            case PlaceYmnosSource.aposticha_orthros_doxastichon:
                stichera = new YmnosStructure()
                {
                    Doxastichon = new YmnosGroup(_dayContainer.Orthros.Aposticha.Doxastichon)
                };
                break;

            case PlaceYmnosSource.aposticha_orthros_theotokion:
                //TODO: прамая ссылка без копирования и клонирования
                stichera = new YmnosStructure()
                {
                    Theotokion = _dayContainer.Orthros.Aposticha.Theotokion
                };
                break;
            }

            return(stichera);
        }