Exemplo n.º 1
0
        public void When_subscribing_value_type()
        {
            Action <int> action = n => { };

            var subs = new Subscriptions();

            var key = subs.Register(TimeSpan.Zero, action);

            key.ShouldNotBeNull();

            subs.IsRegistered(Guid.NewGuid()).ShouldBeFalse();
            subs.IsRegistered(key).ShouldBeTrue();
            subs.UnRegister(key);
            subs.IsRegistered(key).ShouldBeFalse();

            var newKey = subs.Register(TimeSpan.Zero, action);

            subs.IsRegistered(newKey).ShouldBeTrue();
            subs.Clear(false);
            subs.IsRegistered(newKey).ShouldBeFalse();

            var subscriptionsSnapshotMain = subs.GetTheLatestSubscriptions();

            subscriptionsSnapshotMain.Count.ShouldBe(0);

            var keyA = subs.Register(TimeSpan.Zero, action);
            var subscriptionsSnapshotA = subs.GetTheLatestSubscriptions();

            subscriptionsSnapshotA.Count.ShouldBe(1);

            var keyB = subs.Register(TimeSpan.Zero, action);
            var subscriptionsSnapshotB = subs.GetTheLatestSubscriptions();

            subscriptionsSnapshotB.Count.ShouldBe(2);

            subs.IsRegistered(keyA).ShouldBeTrue();
            var subscriptionsSnapshotC = subs.GetTheLatestSubscriptions();

            subscriptionsSnapshotC.Count.ShouldBe(2);
            subscriptionsSnapshotC.ShouldBeSameAs(subscriptionsSnapshotB);

            subs.UnRegister(keyB);
            var subscriptionsSnapshotD = subs.GetTheLatestSubscriptions();

            subscriptionsSnapshotD.Count.ShouldBe(1);

            subs.Clear(false);
            var subscriptionsSnapshotE = subs.GetTheLatestSubscriptions();

            subscriptionsSnapshotE.Count.ShouldBe(0);
        }
 public override void OnViewStopped()
 {
     base.OnViewStopped();
     IsViewVisible = false;
     // Clearing subscriptions to ensure we kill the static event handlers.
     Subscriptions.Clear();
 }
Exemplo n.º 3
0
        public void Load(string xmlFile)
        {
            if (!File.Exists(xmlFile))
            {
                return;
            }

            var xml = File.ReadAllText(xmlFile);

            if (string.IsNullOrEmpty(xml))
            {
                return;
            }
            var config = Serializer.Deserialize(xml);

            Sessions.Clear();
            Connections.Clear();
            Subscriptions.Clear();
            DataCaptures.Clear();

            Sessions.AddRange(config.Sessions);
            Connections.AddRange(config.Connections);
            Subscriptions.AddRange(config.Subscriptions);
            SavedMessages.AddRange(config.SavedMessages);
            DataCaptures.AddRange(config.DataCaptures);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Close message channel
        /// </summary>
        /// <returns></returns>
        public Task Close()
        {
            Processor.Dispose();
            Subscriptions.Clear();

            return(Task.CompletedTask);
        }
Exemplo n.º 5
0
 internal string Reset(IEnumerable <Guid> add)
 {
     lock (Subscriptions)
     {
         Subscriptions.Clear();
         return(Update(add));
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initialize a set of <see cref="IEventAnnouncer"/> types this system will subscribe to for future events.
        /// </summary>
        /// <param name="systems">The types of <see cref="IEventAnnouncer"/> this system will subscribe to.</param>
        public void Subscribe(params Type[] systems)
        {
            Subscriptions.Clear();

            for (int i = 0; i < systems.Length; i++)
            {
                Subscriptions.Add(systems[i]);
            }
        }
Exemplo n.º 7
0
        public async override Task OnDisconnectedAsync(Exception exception)
        {
            foreach (var subscription in Subscriptions.Values)
            {
                subscription.Dispose();
            }
            Subscriptions.Clear();
            BattleHandlerSubscription.Dispose();

            await base.OnDisconnectedAsync(exception);
        }
        public async Task GetSubscriptions()
        {
            var subs = await _subApi.Get <List <Model.Subscription> >(null);

            subs.RemoveAll(s => !s.Available);
            Subscriptions.Clear();
            foreach (var sub in subs)
            {
                Subscriptions.Add(sub);
            }
        }
 public void Clear()
 {
     Observables.Clear();
     Observers.Clear();
     SubjectFactories.Clear();
     SubscriptionFactories.Clear();
     Other.Clear();
     Subscriptions.Clear();
     Subjects.Clear();
     ReliableSubscriptions.Clear();
 }
Exemplo n.º 10
0
        public async void AssignSubscriptions()
        {
            var subscriptions = await DatabaseHelper.ReadSubscriptions();

            if (subscriptions != null)
            {
                Subscriptions.Clear();
                foreach (Subscription s in subscriptions)
                {
                    Subscriptions.Add(s);
                }
            }
        }
Exemplo n.º 11
0
        public virtual void ChangeSubscriptions(IEnumerable <Product> products)
        {
            var subscriptions = products.Select(p => new Subscription(this, p.Code));

            Subscriptions.Clear();
            subscriptions.Each(Subscriptions.Add);
            DomainEvents.Raise(new SubscriptionsChanged
            {
                AccountCode   = Code,
                Subscriptions = subscriptions.Select(s => new SubscriptionInfo {
                    ProductCode = s.ProductCode
                }).ToList()
            });
        }
Exemplo n.º 12
0
        public void When_subscribing_value_type()
        {
            Func <Int32, Task> action = n => Task.CompletedTask;
            var key = Subscriptions.Register(TimeSpan.Zero, action);

            key.ShouldNotBeNull();

            Subscriptions.IsRegistered(Guid.NewGuid()).ShouldBeFalse();
            Subscriptions.IsRegistered(key).ShouldBeTrue();
            Subscriptions.UnRegister(key);
            Subscriptions.IsRegistered(key).ShouldBeFalse();

            var newKey = Subscriptions.Register(TimeSpan.Zero, action);

            Subscriptions.IsRegistered(newKey).ShouldBeTrue();
            Subscriptions.Clear();
            Subscriptions.IsRegistered(newKey).ShouldBeFalse();

            var subscriptionsSnapshotMain = Subscriptions.GetTheLatestSubscriptions();

            subscriptionsSnapshotMain.Length.ShouldBe(0);

            var keyA = Subscriptions.Register(TimeSpan.Zero, action);
            var subscriptionsSnapshotA = Subscriptions.GetTheLatestSubscriptions();

            subscriptionsSnapshotA.Length.ShouldBe(1);

            var keyB = Subscriptions.Register(TimeSpan.Zero, action);
            var subscriptionsSnapshotB = Subscriptions.GetTheLatestSubscriptions();

            subscriptionsSnapshotB.Length.ShouldBe(2);

            Subscriptions.IsRegistered(keyA).ShouldBeTrue();
            var subscriptionsSnapshotC = Subscriptions.GetTheLatestSubscriptions();

            subscriptionsSnapshotC.Length.ShouldBe(2);
            subscriptionsSnapshotC.ShouldBeSameAs(subscriptionsSnapshotB);

            Subscriptions.UnRegister(keyB);
            var subscriptionsSnapshotD = Subscriptions.GetTheLatestSubscriptions();

            subscriptionsSnapshotD.Length.ShouldBe(1);

            Subscriptions.Clear();
            var subscriptionsSnapshotE = Subscriptions.GetTheLatestSubscriptions();

            subscriptionsSnapshotE.Length.ShouldBe(0);
        }
Exemplo n.º 13
0
        public void Close()
        {
            foreach (List <IAsyncSubscription> subscriptions in Subscriptions.Values)
            {
                foreach (var subscription in subscriptions)
                {
                    subscription.Unsubscribe();
                }
            }

            foreach (var connection in ConnectionsByName.Values)
            {
                connection.Close();
            }

            Subscriptions.Clear();
            ConnectionsByName.Clear();
        }
Exemplo n.º 14
0
        private async void ExecuteLoadSubscriptionsCommand(object obj)
        {
            IsBusy = true;
            try
            {
                Subscriptions.Clear();

                var task1 = SubscriptionsService.GetSubscriptionsAsync();

                foreach (var subscription in await task1)
                {
                    Subscriptions.Add(subscription);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                await Application.Current.MainPage.DisplayAlert("BŁĄD", "Nie udało się wczytać rezerwacji", "ANULUJ");
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 15
0
 public virtual void OnViewUnloaded()
 {
     Subscriptions.Clear();
 }
Exemplo n.º 16
0
 public void Delete()
 {
     // This will just clear the subscription association from User but not delete the subscriptions - Is this the intended behavior?
     Subscriptions?.Clear();
 }
Exemplo n.º 17
0
        public async Task GetData()
        {
            var notifications = await _usersApi.GetItems <List <Model.Notification> >(APIService.User.UserId, "Notifications");

            if (notifications.Count == 0)
            {
                HasNotifications = "False";
            }
            else
            {
                HasNotifications = "True";
            }

            var orders = await _ordersApi.Get <List <Model.Order> >(null);

            orders.RemoveAll(o => o.UserId != APIService.User.UserId);
            Orders.Clear();
            foreach (var order in orders)
            {
                var app = await _appsApi.GetById <Model.Appointments>(order.AppointmentId);

                var cdm = await _cdmsApi.GetById <Model.CinemaDayMovie>(app.CinemaDayMovieId);

                var movie = await _moviesApi.GetById <Model.Movie>(cdm.MovieId);

                var adoc = await _adocApi.GetById <Model.AiringDaysOfCinema>(cdm.AiringDaysOfCinemaId);

                var cinema = await _cinemaApi.GetById <Model.Cinema>(adoc.CinemaId);

                var ad = await _adApi.GetById <Model.AiringDay>(adoc.AiringDayId);

                var today = DateTime.Now.Date;
                if (adoc.Date >= today)
                {
                    Model.ObservableLists.OrderItem newItem = new Model.ObservableLists.OrderItem()
                    {
                        Time    = app.StartsAt,
                        Movie   = movie.Title,
                        OrderId = order.OrderId,
                        Total   = order.Total,
                        Date    = adoc.Date.ToString("dd. MMM yyyy"),
                        Seats   = order.Tickets.Count,
                        Cinema  = cinema.Name,
                        Day     = ad.Name
                    };
                    Orders.Add(newItem);
                }
            }

            var movies = await _usersApi.GetItems <List <Model.Movie> >(APIService.User.UserId, "Movies");

            movies.Sort((a, b) => a.Title.CompareTo(b.Title));
            Movies.Clear();
            foreach (var movie in movies)
            {
                Movies.Add(movie);
            }

            var shows = await _usersApi.GetItems <List <Model.Show> >(APIService.User.UserId, "Shows");

            shows.Sort((a, b) => a.Title.CompareTo(b.Title));
            Shows.Clear();
            foreach (var show in shows)
            {
                Shows.Add(show);
            }

            var subscriptions = await _usersApi.GetItems <List <Model.Subscription> >(APIService.User.UserId, "Subscriptions");

            Subscriptions.Clear();
            foreach (var subscription in subscriptions)
            {
                Subscriptions.Add(subscription);
            }

            var rotations = await _usersApi.GetItems <List <Model.Rotation> >(APIService.User.UserId, "Rotations");

            Rotations.Clear();
            foreach (var rotation in rotations)
            {
                var movie = await _moviesApi.GetById <Model.Movie>(rotation.MovieId);

                var show = await _showsApi.GetById <Model.Show>(rotation.ShowId);

                var newItem = new Model.ObservableLists.RotationItem()
                {
                    Birthday    = rotation.ForBirthday,
                    From        = rotation.From.Date.ToString("dd. MMMM yy"),
                    To          = rotation.To.ToString("dd. MMMM yy"),
                    Description = rotation.Description,
                    MovieImage  = movie.ImageLink,
                    ShowImage   = show.ImageLink,
                    RotationId  = rotation.RotationId
                };

                Rotations.Add(newItem);
            }
        }