Exemple #1
0
        /// <summary>
        /// function handles reject order
        /// </summary>
        /// <param name="order"></param>
        public void RejectOrder(Order order)
        {
            order.Reject = false;

            foreach (ValidatorResult result in order.ValidatorResult)
            {
                if (result.Code != ValidatorCodeEnum.OK)
                {
                    order.Reject = true;
                    break;
                }
            }

            if (order.Reject)
            {
                //logic to handle order rejection goes here
                //...
            }
        }
Exemple #2
0
 public abstract ValidatorResult Validate(Order order);
Exemple #3
0
        /// <summary>
        /// function helps apply validators to the order
        /// </summary>
        /// <param name="order"></param>
        public void ApplyValidators(Order order)
        {
            if (order.ValidatorResult == null)
                order.ValidatorResult = new List<ValidatorResult>();

            //if there's no registered validator
            if (_validators.Count == 0)
            {
                ValidatorResult result = new ValidatorResult() { Code = ValidatorCodeEnum.OK };
                order.ValidatorResult.Add(result);

                return;
            }

            foreach (Validator validator in _validators.Values)
            {
                ValidatorResult result = validator.Validate(order);
                order.ValidatorResult.Add(result);
            }
        }