public override DayElementBase Calculate(RuleHandlerSettings settings) { Kontakion result = null; if (!ThrowExceptionIfInvalid(settings)) { //разбираемся с source DayContainer day = GetDayContainer(settings); var kontakia = day?.Orthros?.Kontakia; //не выдаем ошибки, если день не найден if (kontakia != null) { //теперь разбираемся с place switch (Place) { case KontakionPlace.orthros1: { result = (kontakia.Count > 0) ? kontakia[0] : null; } break; case KontakionPlace.orthros2: { result = (kontakia.Count > 1) ? kontakia[1] : null; } break; } } } return(result); }
private ExapostilarionItem GetYmnos(DayContainer day) { ExapostilarionItem result = null; switch (Place) { case ExapostilarionItemPlace.Exap1: { result = (day.Orthros?.Exapostilarion?.Ymnis.Count > 0) ? day.Orthros.Exapostilarion.Ymnis[0] : null; } break; case ExapostilarionItemPlace.Exap2: { result = (day.Orthros?.Exapostilarion?.Ymnis.Count > 1) ? day.Orthros.Exapostilarion.Ymnis[1] : null; } break; case ExapostilarionItemPlace.Theotokion: { result = day.Orthros?.Exapostilarion?.Theotokion; } break; } return(result); }
public DayContainerService(DayContainer dayContainer) { if (dayContainer == null) { throw new ArgumentNullException("DayContainer"); } _dayContainer = dayContainer; }
public void AddAtNewHours() { var dc = new DayContainer(); dc.Update(new TestIncomingRecordData() { LoadedDateTime = DateTime.Now.AddHours(1) }); Assert.That(dc.GetHours().Item1.Count, Is.EqualTo(2)); }
/// <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 List <ExapostilarionItem> GetYmnis(DayContainer day) { List <ExapostilarionItem> result = null; if (GetYmnos(day) is ExapostilarionItem item) { result = new List <ExapostilarionItem>(); for (int i = Count; i > 0; i--) { result.Add(item); } } return(result); }
public Exapostilarion GetStructure(RuleHandlerSettings settings) { Exapostilarion result = null; if (!ThrowExceptionIfInvalid(settings)) { //разбираемся с source DayContainer day = GetDayContainer(settings); //не выдаем ошибки, если день не найден if (day != null) { //теперь разбираемся с place И kind switch (Kind) { case ExapostilarionItemKind.Exap: { List <ExapostilarionItem> ymnis = GetYmnis(day); if (ymnis != null) { result = new Exapostilarion(); result.Ymnis.AddRange(ymnis); } } break; case ExapostilarionItemKind.Theotokion: { ExapostilarionItem ymnos = GetYmnos(day); if (ymnos != null) { result = new Exapostilarion { Theotokion = ymnos }; } } break; } } } return(result); }
public MainViewModel(ActivityList parkingLot, DayContainer dayContainer) { _parkingLot = parkingLot; _dayContainer = dayContainer; ParkedActivities = new ObservableCollection <Activity>(); foreach (var activity in _parkingLot.Activities) { ParkedActivities.Add(activity); } Days = new ObservableCollection <Day>(); foreach (var day in _dayContainer.Days) { Days.Add(day); } _parkingLot.Added += (sender, activity) => ParkedActivities.Add(activity); _parkingLot.Removed += (sender, activity) => ParkedActivities.Remove(activity); EditingState = new ActivityEditingState(); }
protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); _config = new FirebaseConfig { AuthSecret = "CspEtEGUeNNHBAx7wW5u1ovygAsnUUZeueSQHfXV", BasePath = "https://flickering-fire-5452.firebaseio.com/" }; _client = new FirebaseClient(_config); // Show a splash screen var splashScreen = new SplashScreen("Resources/SplashScreen.png"); splashScreen.Show(false, true); // Get the stored state var response = await _client.GetAsync("ParkedActivities"); var activities = response.ResultAs <List <Activity> >(); response = await _client.GetAsync("Days"); var daysAsJson = response.ResultAs <JArray>(); var days = new List <Day>(); // Parse the JSON for the stored days and re-create the days before adding them. if (daysAsJson != null && daysAsJson.Any()) { foreach (var dayAsJson in daysAsJson) { // Parse the fields of the day. var date = dayAsJson["Date"].ToObject <Date>(); var beginTime = dayAsJson["BeginTime"].ToObject <TimeSpan>(); // Parse the activities of the day and add them. IEnumerable <Activity> allActivities = null; var activitiesToken = dayAsJson["AllActivities"]; if (activitiesToken != null) { allActivities = activitiesToken.ToObject <IEnumerable <Activity> >(); } var day = new Day(date) { BeginTime = beginTime }; if (allActivities != null) { foreach (var activity in allActivities) { day.AddActivity(activity); } } days.Add(day); } } _dayContainer = new DayContainer(days); _parkingLot = new ActivityList(activities); _mainViewModel = new MainViewModel(_parkingLot, _dayContainer); _mainWindow = new MainWindow(_mainViewModel); splashScreen.Close(TimeSpan.FromMilliseconds(200)); _mainWindow.Show(); }
/// <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)); } }
public void HasInitialHour() { var dc = new DayContainer(); Assert.That(dc.GetHours().Item1.Count, Is.EqualTo(1)); }