예제 #1
0
 /// <summary>
 ///     Get the value that we will expose to the outside
 /// </summary>
 private object GetFinalValue(IOperand op)
 {
     if (ReferenceEquals(op.GetType(), typeof(ErrorValueOperand)))
     {
         // We want to return error wrappers instead of error enums so that formatting will be automatic
         return(((ErrorValueOperand)op).ValueAsErrorWrapper);
     }
     return(op.Value);
 }
예제 #2
0
        public static IEnumerable <IOperand> GetOperands(IOperand operand)
        {
            yield return(operand);

            switch (operand)
            {
            case IUnoOperand o:
                foreach (var item in GetOperands(o.Operand))
                {
                    yield return(item);
                }
                yield break;

            case ICollectionOperand o:
                if (o.InnerOperand != null)
                {
                    foreach (var item in GetOperands(o.InnerOperand))
                    {
                        yield return(item);
                    }
                }
                yield break;

            case IBinaryOperand o:
                foreach (var item in GetOperands(o.Left))
                {
                    yield return(item);
                }
                foreach (var item in GetOperands(o.Right))
                {
                    yield return(item);
                }
                yield break;

            case IParameterizedOperand o:
                yield break;

            case null: throw new ArgumentNullException(nameof(operand));

            default: throw new NotSupportedException(operand.GetType().FullName);
            }
        }