示例#1
0
        public async Task<List<Event>> GetEventsAfterAsync (Event latestEvent, Priority priority)
        {
            List<Event> events = new List<Event> ();
            Task<List<Event>> getEventsTask;

            var timestamp = latestEvent.CreatedAt.ToUnixTimestamp ();

            switch (priority) {
            case Priority.Background:
                getEventsTask = _apiService.Background.GetEventsAfter (timestamp, ApiService.Device);
                break;
            case Priority.UserInitiated:
                getEventsTask = _apiService.UserInitiated.GetEventsAfter (timestamp, ApiService.Device);
                break;
            case Priority.Speculative:
                getEventsTask = _apiService.Speculative.GetEventsAfter (timestamp, ApiService.Device);
                break;
            default:
                getEventsTask = _apiService.UserInitiated.GetEventsAfter (timestamp, ApiService.Device);
                break;
            }

            if (CrossConnectivity.Current.IsConnected)
            {
                events = await Policy
                    .Handle<WebException> ()
                    .WaitAndRetryAsync (2, retryAttempt => TimeSpan.FromSeconds (Math.Pow (2, retryAttempt)))
                    .ExecuteAsync(async () => await getEventsTask);
            }

            return events;
        }
示例#2
0
        public EventViewModel(Event model)
        {
            Model = model;

            Title = model.Title;
            EventTitle = model.Title;
            Location = model.Location;
            Time = model.Time;
            CreatedAt = model.CreatedAt;

            this.WhenAnyValue (x => x.Time)
                .Select (x => x.ToString ("dd MMMM yyyy"))
                .ToProperty (this, x => x.DateText, out dateText);

            this.WhenAnyValue (x => x.Time)
                .Select (x => x.ToString ("HH:mm"))
                .ToProperty (this, x => x.TimeText, out timeText);
        }
        public EventItemViewModel(Event model)
        {
            Model = model;

            Title = model.Title;
            Location = model.Location;
            Time = model.Time;
            CreatedAt = model.CreatedAt;
            Id = model.Id;

            this.WhenAnyValue (x => x.Time)
                .Select (x => x.ToString ("dd MMMM yyyy", new CultureInfo("tr-TR")))
                .ToProperty (this, x => x.DateText, out dateText);

            this.WhenAnyValue (x => x.Time)
                .Select (x => x.ToString ("HH:mm"))
                .ToProperty (this, x => x.TimeText, out timeText);
        }