public CatalogViewModel(IDomainContext domainContext) { isInited = false; HasError = new BoolHolder(); DomainContext = domainContext; HasChanges = false; ShowPhotoOnMouseDoubleClick = false; RefreshView = delegate { }; RefreshDirectoryView = delegate { }; RefreshBrandView = delegate { }; RefreshCatalogView = delegate { }; SetEnabled = delegate { }; HasResultGridErrors = () => false; loadTimer = new Timer(); loadTimer.Interval = 300; TimeSpan.FromMilliseconds(10); loadTimer.Elapsed += LoadData_Tick; //loadQueue = new Queue<Action>(); Model = new CatalogModel(domainContext); CatalogNavigateViewModel = new CatalogNavigateViewModel(this, Model); CatalogDirectoryViewModel = new CatalogDirectoryViewModel(domainContext, Model?.SearchCriteria); CatalogBrandViewModel = new CatalogBrandViewModel(domainContext, Model?.SearchCriteria); SubscribeEvents(); SubscribeMessenger(); InitCommands(); }
public PartialViewResult Notification() { var requests = addFriendRepository.GetAll().Where(request => request.To.Id == User.Identity.GetUserId()).ToList(); var model = new BoolHolder(); model.UserGotRequest = requests.Any(); return(PartialView("_Notification", model)); }
public void Dispose_EnumerableChildren_DisposesAllChildren() { var action1Invoked = new BoolHolder(); var action2Invoked = new BoolHolder(); var disposable = CollectionDisposable.Create(new[] { action1Invoked, action2Invoked }.Select(bh => new AnonymousDisposable(() => { bh.Value = true; }))); disposable.Dispose(); Assert.True(action1Invoked.Value); Assert.True(action2Invoked.Value); }
public async Task Dispose_EnumerableChildren_DisposesAllChildren() { var action1Invoked = new BoolHolder(); var action2Invoked = new BoolHolder(); var disposable = CollectionAsyncDisposable.Create(new[] { action1Invoked, action2Invoked }.Select(bh => new AnonymousAsyncDisposable(async() => { bh.Value = true; }))); await disposable.DisposeAsync(); Assert.True(action1Invoked.Value); Assert.True(action2Invoked.Value); }
private void SubscribeHasError(BoolHolder oldHolder, BoolHolder newHolder) { if (oldHolder != null) { oldHolder.PropertyChanged -= Holder_OnPropertyChanged; } if (newHolder != null) { newHolder.PropertyChanged += Holder_OnPropertyChanged; } }