Exemple #1
0
        protected virtual void ConstructWithCommonRule(CreateViewModelRequest <YmnosStructureRule> req, string key)
        {
            var children = Serializer.GetCommonRuleChildren(req.Handler.Settings.TypiconVersionId, key);

            //List<RuleElement> children = req.Handler.Settings.TypiconRule.Owner.GetChildren(
            //    new CommonRuleServiceRequest() { Key = key, RuleSerializer = Serializer }).ToList();

            if (req.Element.Structure.Groups.Count > 0)
            {
                //заполняем header - вставляем номер гласа
                ItemText header = (children[0] as TextHolder).Paragraphs[0];

                header.ReplaceForEach("[ihos]", req.Element.Structure.Groups[0].Ihos);
                //string headerText = header.StringExpression;
                //header.StringExpression = headerText.Replace("[ihos]",
                //    req.Handler.Settings.Language.IntConverter.ToString(req.Element.Structure.Groups[0].Ihos));

                //а теперь отсчитываем от последней стихиры и добавляем к ней стих из псалма
                //сам стих удаляем из псалма

                TextHolder psalm = new TextHolder(children[2] as TextHolder);

                for (int i = req.Element.Structure.Groups.Count - 1; i >= 0; i--)
                {
                    YmnosGroup group = req.Element.Structure.Groups[i];

                    for (int n = group.Ymnis.Count - 1; n >= 0; n--)
                    {
                        Ymnos ymnos = group.Ymnis[n];

                        ItemTextNoted stihos = psalm.Paragraphs.Last();

                        ymnos.Stihoi.Add(stihos);

                        psalm.Paragraphs.Remove(stihos);
                    }
                }
            }

            //теперь вставляем шапку
            AppendItem(children[0] as TextHolder);
            AppendItem(children[1] as TextHolder);

            //вставляем псалмы
            if ((req.Element as KekragariaRule).ShowPsalm)
            {
                AppendItem(children[2] as TextHolder);
            }

            void AppendItem(TextHolder textHolder)
            {
                req.AppendModelAction(new OutputSectionModelCollection()
                {
                    OutputSectionFactory.Create(textHolder, req.Handler.Settings.TypiconVersionId, Serializer)
                });
            }
        }
Exemple #2
0
        public static void AppendViewModel(this Prosomoion prosomoion, int typiconVersionId,
                                           IRuleSerializerRoot serializer, OutputSectionModelCollection viewModel, int?ihos = null)
        {
            ItemText ihosItemText       = null;
            ItemText prosomoionItemText = null;

            if (ihos != null)
            {
                //текст "Глас"
                ihosItemText = serializer.GetCommonRuleItemTextValue(typiconVersionId, CommonRuleConstants.IhosText);
                ihosItemText.ReplaceForEach("[ihos]", ihos.Value);
            }
            else
            {
                ihosItemText = new ItemText();
            }

            //самоподобен?
            if (prosomoion?.Self == true)
            {
                prosomoionItemText = serializer.GetCommonRuleItemTextValue(typiconVersionId, CommonRuleConstants.SelfText);
            }
            //если подобен
            else if (prosomoion?.IsEmpty == false)
            {
                prosomoionItemText = serializer.GetCommonRuleItemTextValue(typiconVersionId, CommonRuleConstants.ProsomoionText);
                prosomoionItemText.ReplaceForEach("[name]", prosomoion);
            }
            else
            {
                prosomoionItemText = new ItemText();
            }

            //соединяем воедино
            ihosItemText.Merge(prosomoionItemText);

            viewModel.Add(OutputSectionFactory.Create(TextHolderKind.Text,
                                                      new List <ItemTextNoted> {
                new ItemTextNoted(ihosItemText)
            }));
        }