Exemplo n.º 1
0
        protected override Task Init()
        {
            _collection = new ObjectRepositoryServerObservableCollection <MoneyColumnMetadataModel, MoneyColumnMetadataStream>(
                ObjectRepository,
                SendUpdate,
                (x, i) => new MoneyColumnMetadataStream {
                Added = ToStream(x)
            },
                (x, i) => new MoneyColumnMetadataStream {
                Removed = ToStream(x)
            },
                (x, i) => new MoneyColumnMetadataStream {
                Updated = ToStream(x)
            },
                list =>
            {
                var model = new MoneyColumnMetadataStream {
                    Snapshot = new MoneyColumnMetadataList()
                };
                model.Snapshot.MoneyColumnMetadatas.AddRange(list.Select(ToStream).ToList());
                return(model);
            });

            Anchors.Add(() => _collection.Dispose());

            return(Task.CompletedTask);
        }
        protected override Task Init()
        {
            _collection = new ObjectRepositoryServerObservableCollection <SpentCategoryModel, SpentCategoriesStream>(
                ObjectRepository,
                SendUpdate,
                (x, i) => new SpentCategoriesStream {
                Added = ToSpentCategory(x)
            },
                (x, i) => new SpentCategoriesStream {
                Removed = ToSpentCategory(x)
            },
                (x, i) => new SpentCategoriesStream {
                Updated = ToSpentCategory(x)
            },
                list =>
            {
                var model = new SpentCategoriesStream {
                    Snapshot = new SpentCategoryList()
                };
                model.Snapshot.SpentCategories.AddRange(list.Select(ToSpentCategory).ToList());
                return(model);
            });

            Anchors.Add(() => _collection.Dispose());

            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
        protected override Task Init()
        {
            _collection = new ServerObservableCollection <PaymentsMonthViewModel, PaymentsStream>(SendUpdate, PaymentTransformers.OnAdd, PaymentTransformers.OnRemove, PaymentTransformers.OnUpdate);

            _collection.SendUpdates = false;

            foreach (PaymentModel v in ObjectRepository.Set <PaymentModel>())
            {
                AddPayment(v);
            }

            SendUpdate(new PaymentsStream
            {
                Snapshot = new PaymentsList
                {
                    ShowCategorized = ShowCategorized,
                    Payments        = { _collection.Select(v => v.ToMonthSummary()) }
                }
            });

            _collection.SendUpdates = true;

            return(Task.CompletedTask);
        }