public async override Task <bool> TryAddAsync(TKey key, IPositionList <TItem> value, bool overwrite = false, CancellationToken cancellationToken = default) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } var internalSet = value as InternalList; if (internalSet != null) { return(internalSet.Key.Equals(key) && overwrite); } var database = GetDatabase() as IDatabase; if (database == null) { throw new NotSupportedException("The database instance type is not supported"); } var redisKey = GetRedisKey(key); if (await database.KeyExistsAsync(redisKey, ReadFlags) && !overwrite) { return(false); } var transaction = database.CreateTransaction(); var commandTasks = new System.Collections.Generic.List <Task>(); if (overwrite) { commandTasks.Add(transaction.KeyDeleteAsync(redisKey, WriteFlags)); } internalSet = CreateList(key, transaction); var enumerableAsync = await value.AsEnumerableAsync().ConfigureAwait(false); await enumerableAsync.ForEachAsync(item => { commandTasks.Add(internalSet.AddAsync(item)); }, CancellationToken.None).ConfigureAwait(false); var success = await transaction.ExecuteAsync(WriteFlags).ConfigureAwait(false); await Task.WhenAll(commandTasks).ConfigureAwait(false); return(success); }
public PositionListFacade(IPositionList positionList, ISizeList sizeList, IIngredientList ingredientList) { this.positionList = positionList; this.sizeList = sizeList; this.ingredientList = ingredientList; positionList.PositionListChanged += UpdatePositions; sizeList.SizeListChanged += UpdateSizes; ingredientList.IngredientListChanged += UpdateIngredients; }
public PositionListValidator(IPositionList positionListFeedback) { this.positionListFeedBack = positionListFeedback; positionListFeedback.PositionListChanged += OnPositionListChange; }