예제 #1
0
 /// <summary>
 /// Gets the color.
 /// </summary>
 /// <param name="checkSeverity">The check severity.</param>
 /// <returns>A color resource.</returns>
 private static IDisposable GetColor(CheckSeverity checkSeverity)
 {
     if (checkSeverity == CheckSeverity.Error)
     {
         return(Color.Failed);
     }
     else
     {
         return(Color.Warning);
     }
 }
예제 #2
0
 /// <summary>
 /// Call this method from within your Run() method.
 /// Each call to Check() produces one entry in the log.
 /// Use your customized message creator in order to build a dynamic message based on the execution of exp.
 /// </summary>
 /// <param name="exp"></param>
 /// <param name="mc">Message creator is executed after exp executes. This gives you a chance to modify the content of the message in the exp by
 /// passing context information into mc and creating custom logic in your MC implementation of GetMessage().</param>
 /// <param name="severity">Specify the severity of the check.</param>
 /// <returns></returns>
 public bool Check(COExpression <LocResource> exp, MessageCreator mc, CheckSeverity severity)
 {
     return(base._AgnosticCheckandLog(ExpressionCaster(exp), mc, severity));
 }
예제 #3
0
 public bool Check(COExpression <LocResource> exp, string message, CheckSeverity severity)
 {
     return(Check(exp, ref message, severity));
 }
예제 #4
0
 public bool Check(COExpression <LocResource> exp, ref string message, CheckSeverity severity)
 {
     return(base._AgnosticCheckandLog(this.ExpressionCaster(exp), ref message, severity));
 }
예제 #5
0
        /// <summary>
        /// Perform checking and log result (String constructor)
        /// </summary>
        /// <param name="exp">Lambda expression</param>
        /// <param name="message">string representation of the message</param>
        /// <param name="severity">CheckSeverity</param>
        /// <returns></returns>
        protected internal bool _AgnosticCheckandLog(COExpression <ClassificationObject> exp, ref string message, CheckSeverity severity)
        {
            bool result;
            ExecutingRuleException ruleException = null;

            try
            {
                result = exp(_currentCO);
            }
            catch (Exception e)
            {
                if (e is OutOfMemoryException || e is StackOverflowException)
                {
                    throw;
                }
                result  = false;
                message = String.Format(CultureInfo.CurrentCulture, "Rule :{0}, Check() call: \"{1}\" threw an exception.",
                                        this.GetType().Name, message);
                ruleException = new ExecutingRuleException(message, e);
            }
            if (!String.IsNullOrEmpty(message))
            {
                message = Engine.ResourceStaticAnalysisEngine.StringCache.Intern(message);
            }
            else
            {
                message = String.Empty;
            }
            OutputItem oi = new OutputItem {
                Message = message, Result = result, Severity = severity
            };

            currentOutputEntry.AddItem(oi);
            if (ruleException != null)
            {
                throw ruleException;
            }
            return(oi.Result);
        }