Exemplo n.º 1
0
        public void FirstApplyTest()
        {
            init();
            var actualValue = Operation.Apply(set1, set2);

            Assert.Equal(expectedValue, actualValue);
        }
Exemplo n.º 2
0
 void IWorkWithSharedTransactionalBatch.AddOperation(IOperation operation)
 {
     if (TransactionalBatch == null)
     {
         return;
     }
     operation.Apply(TransactionalBatch, PartitionKeyPath);
 }
Exemplo n.º 3
0
        public void AddOperation(IOperation op)
        {
            State?newState = op.Apply(CurrentState);

            if (newState == null)
            {
                return;
            }

            States.Add(newState.Value);
        }
        public float Calculate(float left, float right, string operation)
        {
            IOperation _operation = _availableOperations.Find(x => x.OperationCode == operation);

            if (_operation != null)
            {
                return(_operation.Apply(left, right));
            }
            else
            {
                throw new InvalidOperationException($"Operation {operation} isn't supported");
            }
        }
    public void Redo()
    {
        if (redoOperations.Count == 0)
        {
            return;
        }
        IOperation op = redoOperations.Pop();

        op.Apply();
        undoOperations.Push(op);
        source.PlayOneShot(redoAudio);
        Debug.Log($"Redo: {op.GetType().Name}");
        OnStacksChanged?.Invoke();
    }
Exemplo n.º 6
0
        public int Calculate(string inputString)
        {
            string[] numbersAndOperations = Regex
                                            .Replace(inputString, @"([\d]+)", "'$1'")
                                            .Split(new[] { '\'' }, StringSplitOptions.RemoveEmptyEntries);

            int result = int.Parse(numbersAndOperations[0]);

            for (int i = 1; i < numbersAndOperations.Length; i += 2)
            {
                string     operationCode = numbersAndOperations[i].Trim();
                IOperation operation     = _supportedOperations.Find(x => x.OperatorCode == operationCode);
                int        number        = int.Parse(numbersAndOperations[i + 1]);
                result = operation.Apply(result, number);
            }
            return(result);
        }
Exemplo n.º 7
0
        internal static async Task ExecuteOperationAsync(this TransactionalBatch transactionalBatch, IOperation operation, PartitionKeyPath partitionKeyPath, CancellationToken cancellationToken = default)
        {
            operation.Apply(transactionalBatch, partitionKeyPath);

            using (var batchOutcomeResponse = await transactionalBatch.ExecuteAsync(cancellationToken).ConfigureAwait(false))
            {
                if (batchOutcomeResponse.Count > 1)
                {
                    throw new Exception($"The transactional batch was expected to have a single operation but contained {batchOutcomeResponse.Count} operations.");
                }

                var result = batchOutcomeResponse[0];

                if (result.IsSuccessStatusCode)
                {
                    operation.Success(result);
                    return;
                }

                // guaranteed to throw
                operation.Conflict(result);
            }
        }
Exemplo n.º 8
0
 public void Execute(IOperation operation)
 {
     operation.Apply(this);
 }
 public void Apply(IOperation <T> op)
 {
     stack = op.Apply(stack);
 }
Exemplo n.º 10
0
 public void Execute(IOperation operation)
 {
     operation.Apply(heading: this);
 }