当前位置: 首页>>代码示例>>C#>>正文


C# ObservableCollection.ObserveCollection方法代码示例

本文整理汇总了C#中ObservableCollection.ObserveCollection方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.ObserveCollection方法的具体用法?C# ObservableCollection.ObserveCollection怎么用?C# ObservableCollection.ObserveCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObservableCollection的用法示例。


在下文中一共展示了ObservableCollection.ObserveCollection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BlotterRowAdapter

        public BlotterRowAdapter(RecyclerView recyclerView, ObservableCollection<ITradeViewModel> tradesCollection)
        {
            _tradesCollection = tradesCollection;
            
            var animator = new BlotterRowAnimator();
            recyclerView.SetItemAnimator(animator);

            _tradesCollection = tradesCollection;
            _collectionChangedSubscription = _tradesCollection.ObserveCollection()
                .Subscribe(changeArgs =>
                {
                    if (_animationsEnabled && changeArgs.Action == NotifyCollectionChangedAction.Add && changeArgs.NewItems.Count == 1)
                    {
                        Console.WriteLine($"Count: {_tradesCollection.Count}");
                        NotifyItemInserted(changeArgs.NewStartingIndex);
                        recyclerView.SmoothScrollToPosition(0);
                    }
                    else
                    {
                        NotifyDataSetChanged();

                        if (!_animationsEnabled)
                        {
                            recyclerView.ScrollToPosition(0);
                        }
                    }
                });

            _tradesCollection.ObserveCollection()
                .FirstAsync()
                .Delay(TimeSpan.FromSeconds(1))
                .Subscribe(_ =>
                {
                    _animationsEnabled = true;
                });
        }
开发者ID:tomgilder,项目名称:ReactiveTrader,代码行数:36,代码来源:BlotterRowAdapter.cs

示例2: UpsertInventories

		public void UpsertInventories(IEnumerable<coreModel.InventoryInfo> inventoryInfos)
		{
			using (var repository = _repositoryFactory())
			{
				var sourceEntities = inventoryInfos.Select(x => x.ToDataModel()).ToList();
				var changedProductIds = inventoryInfos.Select(x => x.ProductId).ToArray();
				var targetEntities = repository.GetProductsInventories(changedProductIds).ToList();

				var targetCollection = new ObservableCollection<dataModel.Inventory>(targetEntities);
				targetCollection.ObserveCollection(x => repository.Add(x), null);
				var inventoryComparer = AnonymousComparer.Create((dataModel.Inventory x) => x.FulfillmentCenterId + "-" + x.Sku);
				sourceEntities.Patch(targetCollection, inventoryComparer, (source, target) => source.Patch(target));

				CommitChanges(repository);
			}
		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:16,代码来源:InventoryServiceImpl.cs

示例3: SpotTileAdapter

        public SpotTileAdapter(ObservableCollection<ISpotTileViewModel> spotTileCollection, IConcurrencyService concurrencyService)
        {
            _spotTileCollection = spotTileCollection;
            _concurrencyService = concurrencyService;

            _collectionChangedSubscription = _spotTileCollection
                .ObserveCollection()
                .Throttle(TimeSpan.FromMilliseconds(10))
                .ObserveOn(_concurrencyService.Dispatcher)
                .Subscribe(async eventArgs =>
                {
                    switch (eventArgs.Action)
                    {
                        case NotifyCollectionChangedAction.Add:
                            
                            NotifyItemRangeInserted(eventArgs.NewStartingIndex, eventArgs.NewItems.Count);
                            break;

                        case NotifyCollectionChangedAction.Remove:

                            NotifyItemRangeRemoved(eventArgs.OldStartingIndex, eventArgs.OldItems.Count);
                            break;

                        default:

                            _allSubscriptions.Clear();
                            NotifyDataSetChanged();
                            break;
                    }

					if (_animate)
					{
						await Task.Delay(3000);
						_animate = false;
					}
                });
        }
开发者ID:tomgilder,项目名称:ReactiveTrader,代码行数:37,代码来源:SpotTileAdapter.cs

示例4: Update

		public void Update(coreModel.CatalogProduct[] items)
		{
			var now = DateTime.UtcNow;
			using (var repository = _catalogRepositoryFactory())
			using (var changeTracker = base.GetChangeTracker(repository))
			{
				var dbItems = repository.GetItemByIds(items.Select(x => x.Id).ToArray(), coreModel.ItemResponseGroup.ItemLarge);
				foreach (var dbItem in dbItems)
				{
					var item = items.FirstOrDefault(x => x.Id == dbItem.Id);
					if (item != null)
					{
						//Need skip inherited properties without overridden value
						if (dbItem.ParentId != null && item.PropertyValues != null)
						{
							var dbParentItem = repository.GetItemByIds(new[] { dbItem.ParentId }, coreModel.ItemResponseGroup.ItemProperties).First();
							item.MainProduct = dbParentItem.ToCoreModel(new coreModel.Catalog { Id = dbItem.CatalogId }, new coreModel.Category { Id = dbItem.CategoryId }, null);
						}

						changeTracker.Attach(dbItem);

						item.Patch(dbItem);
					}

					//Patch seoInfo
					if (item.SeoInfos != null)
					{
						foreach (var seoInfo in item.SeoInfos)
						{
							seoInfo.ObjectId = item.Id;
							seoInfo.ObjectType = typeof(coreModel.CatalogProduct).Name;
						}
						var seoInfos = new ObservableCollection<SeoInfo>(_commerceService.GetObjectsSeo(new[] { item.Id }));
						seoInfos.ObserveCollection(x => _commerceService.UpsertSeo(x), x => _commerceService.DeleteSeo(new[] { x.Id }));
						item.SeoInfos.Patch(seoInfos, (source, target) => _commerceService.UpsertSeo(source));
					}
				}
				CommitChanges(repository);
			}

		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:41,代码来源:ItemServiceImpl.cs

示例5: Update

        public void Update(coreModel.Store[] stores)
        {
            using (var repository = _repositoryFactory())
            using (var changeTracker = base.GetChangeTracker(repository))
            {
                foreach (var store in stores)
                {
                    var sourceEntity = store.ToDataModel();
                    var targetEntity = repository.GetStoreById(store.Id);

                    if (targetEntity == null)
                    {
                        throw new NullReferenceException("targetEntity");
                    }

                    changeTracker.Attach(targetEntity);
                    sourceEntity.Patch(targetEntity);

                    _dynamicPropertyService.SaveDynamicPropertyValues(store);
                    //Deep save settings
                    _settingManager.SaveEntitySettingsValues(store);

                    //Patch SeoInfo  separately
                    if (store.SeoInfos != null)
                    {
                        foreach (var seoInfo in store.SeoInfos)
                        {
                            seoInfo.ObjectId = store.Id;
                            seoInfo.ObjectType = typeof(coreModel.Store).Name;
                        }

                        var seoInfos = new ObservableCollection<SeoInfo>(_commerceService.GetObjectsSeo(new[] { store.Id }));
                        seoInfos.ObserveCollection(x => _commerceService.UpsertSeo(x), x => _commerceService.DeleteSeo(new[] { x.Id }));
                        store.SeoInfos.Patch(seoInfos, (source, target) => _commerceService.UpsertSeo(source));
                    }

					//Reset cache
					var cacheKey = CacheKey.Create("StoreModule", "GetById", store.Id);
					_cacheManager.Remove(cacheKey);
                }

                CommitChanges(repository);
            }
        }
开发者ID:nisarzahid,项目名称:vc-community,代码行数:44,代码来源:StoreServiceImpl.cs

示例6: Update

        public void Update(coreModel.Category[] categories)
        {
            using (var repository = _catalogRepositoryFactory())
			using (var changeTracker = base.GetChangeTracker(repository))
            {
				foreach (var category in categories)
				{
					var dbCategory = repository.GetCategoryById(category.Id) as dataModel.Category;
					
					if (dbCategory == null)
					{
						throw new NullReferenceException("dbCategory");
					}

					//Patch SeoInfo  separately
					if (category.SeoInfos != null)
					{
						foreach(var seoInfo in category.SeoInfos)
						{
							seoInfo.ObjectId = category.Id;
							seoInfo.ObjectType = typeof(coreModel.Category).Name;
						}
						var seoInfos = new ObservableCollection<SeoInfo>(_commerceService.GetObjectsSeo(new string[] { category.Id}));
						seoInfos.ObserveCollection(x => _commerceService.UpsertSeo(x), x => _commerceService.DeleteSeo(new string[] { x.Id }));
						category.SeoInfos.Patch(seoInfos, (source, target) => _commerceService.UpsertSeo(source));
					}
		
					var dbCategoryChanged = category.ToDataModel();
					changeTracker.Attach(dbCategory);
				
					dbCategoryChanged.Patch(dbCategory);
				}
				CommitChanges(repository);

			}
        }
开发者ID:alt-soft,项目名称:vc-community,代码行数:36,代码来源:CategoryServiceImpl.cs

示例7: Update

		public void Update(coreModel.Store[] stores)
		{
			using (var repository = _repositoryFactory())
			using (var changeTracker = base.GetChangeTracker(repository))
			{
				foreach (var store in stores)
				{
					var sourceEntity = store.ToDataModel();
					var targetEntity = repository.GetStoreById(store.Id);
					if (targetEntity == null)
					{
						throw new NullReferenceException("targetEntity");
					}

					changeTracker.Attach(targetEntity);
					sourceEntity.Patch(targetEntity);

					SaveObjectSettings(_settingManager, store);

					//Patch SeoInfo  separately
					if (store.SeoInfos != null)
					{
						foreach(var seoInfo in store.SeoInfos)
						{
							seoInfo.ObjectId = store.Id;
							seoInfo.ObjectType = typeof(coreModel.Store).Name;
						}
						var seoInfos = new ObservableCollection<SeoInfo>(_commerceService.GetObjectsSeo(new string[] { store.Id }));
						seoInfos.ObserveCollection(x => _commerceService.UpsertSeo(x), x => _commerceService.DeleteSeo(new string[] { x.Id }));
						store.SeoInfos.Patch(seoInfos, (source, target) => _commerceService.UpsertSeo(source));
					}
				}
				CommitChanges(repository);

			}


		}
开发者ID:alt-soft,项目名称:vc-community,代码行数:38,代码来源:StoreServiceImpl.cs


注:本文中的ObservableCollection.ObserveCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。