示例#1
0
 public virtual void Execute(bool isValidating = false)
 {
     if (ManualExecute)
     {
         return;
     }
     try
     {
         var startTime = DateTime.Now;
         //Evaluate parameters
         foreach (var parameter in Parameters)
         {
             parameter.Value.Execute(isValidating);
         }
         //Evaluate subexpression
         if (SubExpression != null)
         {
             SubExpression.Execute(isValidating);
             Value = SubExpression.Value;
         }
         //Evaluate ExpressionFunction
         if (ExpressionFunction != null)
         {
             Value = ExpressionFunction.Invoke(this);
         }
         //if (Logger.ShouldLog(Logger.Category.Trace, TraceEventType.Information))
         //{
         //    Logger.Info(string.Format("{0} = {1}, cost {2} ms", FullKey, Value, (DateTime.Now - startTime).TotalMilliseconds));
         //}
         //Validate value
         Validate(isValidating);
     }
     catch (ExpressionException ex)
     {
         throw new ExpressionException(string.Format("{0} has error:{1}", FullKey, ex.Message), ex)
               {
                   Expression = ex.Expression
               };
     }
     catch (Exception ex)
     {
         throw new ExpressionException(string.Format("{0} has error:{1}", FullKey, ex.Message), this.GetCommandName(), ex)
               {
                   Expression = this
               };
     }
 }