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); }
public GetTheotokionResponse Get(GetTheotokionRequest request) { GetTheotokionResponse response = new GetTheotokionResponse(); try { TheotokionApp theotokion = _unitOfWork.Repository <TheotokionApp>() .Get(c => c.Ihos == request.Ihos && c.Place == request.Place && c.DayOfWeek == request.DayOfWeek); YmnosGroup group = new YmnosGroup() { Ihos = theotokion.Ihos }; group.Ymnis.Add(theotokion.GetElement(request.Serializer)); response.BookElement = group; } catch (Exception ex) { response.Exception = ex; } return(response); }
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); }
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) }); } }
public static OutputSectionModelCollection GetViewModel(this YmnosGroup group, IRuleHandler handler, IRuleSerializerRoot serializer) { OutputSectionModelCollection viewModel = new OutputSectionModelCollection(); group.Annotation.AppendViewModel(handler, viewModel); group.Prosomoion.AppendViewModel(handler.Settings.TypiconVersionId, serializer, viewModel, group.Ihos); AppendYmnis(group.Ymnis, handler, serializer, viewModel); return(viewModel); }
public static ElementViewModel GetViewModel(this YmnosGroup group, IRuleHandler handler, IRuleSerializerRoot serializer) { ElementViewModel viewModel = new ElementViewModel(); group.Annotation.AppendViewModel(handler, viewModel); group.Prosomoion.AppendViewModel(handler, serializer, viewModel, group.Ihos); AppendYmnis(group.Ymnis, handler, serializer, viewModel); return(viewModel); }
public void YmnosGroupTest_ValidIhos() { string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData"); FileReader reader = new FileReader(folderPath); string xml = reader.Read("YmnosGroupTest.xml"); TypiconSerializer ser = new TypiconSerializer(); YmnosGroup element = ser.Deserialize <YmnosGroup>(xml); Assert.IsTrue(element.IsValid); }
public YmnosGroupViewModel(YmnosGroup group, IRuleHandler handler, IRuleSerializerRoot serializer) { if (group == null || group.Ymnis == null) { throw new ArgumentNullException("YmnosGroup"); } _group = group; _handler = handler ?? throw new ArgumentNullException("handler"); Serializer = serializer ?? throw new ArgumentNullException("IRuleSerializerRoot"); Ihos = group.Ihos; if (group.Annotation?.IsEmpty == false) { Annotation = group.Annotation[handler.Settings.Language]; } //текст "Глас" CommonRuleServiceRequest req = new CommonRuleServiceRequest() { RuleSerializer = Serializer }; req.Key = CommonRuleConstants.IhosText; IhosText = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language); //если подобен if (group.Prosomoion?.IsEmpty == false) { req.Key = CommonRuleConstants.ProsomoionText; Prosomoion = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language); Prosomoion = string.Format(@"{0}: ""{1}""", Prosomoion, group.Prosomoion[handler.Settings.Language]); } //самоподобен? if (group.Prosomoion?.Self == true) { req.Key = CommonRuleConstants.SelfText; Self = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language); } //находим Стих и Хор для дальнешей вставки req.Key = CommonRuleConstants.StihosRule; _kindStihosValue = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language); req.Key = CommonRuleConstants.ChoirRule; _kindChoirValue = handler.Settings.Rule.Owner.GetCommonRuleTextValue(req, handler.Settings.Language); }
public void YmnosGroupTest_Equals3() { var element1 = new YmnosGroup() { Ihos = 1, Annotation = new ItemText() }; element1.Annotation.AddOrUpdate("cs-ru", "Феофа́ново"); var element2 = new YmnosGroup() { Ihos = 1, Annotation = new ItemText() }; element2.Annotation.AddOrUpdate("cs-cs", "Феофа́ново"); Assert.IsFalse(element1.Equals(element2)); }
public void YmnosGroupTest_Equals3() { YmnosGroup element1 = new YmnosGroup() { Annotation = new ItemText(@"<annotation> <item language=""cs-ru"">Феофа́ново</item> </annotation>"), Ihos = 1, //Prosomoion = new Prosomoion() }; YmnosGroup element2 = new YmnosGroup() { Annotation = new ItemText(@"<annotation> <item language=""cs-cs"">Феофа́ново</item> </annotation>"), Ihos = 1, //Prosomoion = new Prosomoion() }; Assert.IsFalse(element1.Equals(element2)); }
public void YmnosGroupTest_Serialization() { string xmlString = @"<YmnosGroup ihos=""4""> <prosomoion> <item language=""cs-ru"">Ки́ими похва́льными.</item> </prosomoion> <ymnos> <stihos> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, Стих 1-й стихиры.</item> </stihos> <text> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, 1 стихира.</item> </text> </ymnos> <ymnos> <stihos> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, Стих 2-й стихиры.</item> </stihos> <text> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, 2 стихира.</item> </text> </ymnos> <ymnos> <stihos> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, Стих 3-й стихиры.</item> </stihos> <text> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, 3 стихира.</item> </text> </ymnos> </YmnosGroup>" ; TypiconSerializer ser = new TypiconSerializer(); YmnosGroup element = ser.Deserialize <YmnosGroup>(xmlString); string result = ser.Serialize(element); Assert.Pass(result); }
public void YmnosGroupTest_Deserialization() { string xmlString = @"<YmnosGroup ihos=""4""> <prosomoion> <item language=""cs-ru"">Ки́ими похва́льными.</item> </prosomoion> <ymnos> <stihos> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, Стих 1-й стихиры.</item> </stihos> <text> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, 1 стихира.</item> </text> </ymnos> <ymnos> <stihos> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, Стих 2-й стихиры.</item> </stihos> <text> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, 2 стихира.</item> </text> </ymnos> <ymnos> <stihos> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, Стих 3-й стихиры.</item> </stihos> <text> <item language=""cs-ru"">[item] [sign] Малая вечерня. На стиховне, 3 стихира.</item> </text> </ymnos> </YmnosGroup>" ; TypiconSerializer ser = new TypiconSerializer(); YmnosGroup element = ser.Deserialize <YmnosGroup>(xmlString); Assert.AreEqual(element.Ymnis.Count, 3); Assert.AreEqual(element.Ihos, 4); Assert.IsNull(element.Annotation); }
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); } }
/// <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); }