/// <summary> /// Removes a log associated to a model element /// </summary> /// <param name="log"></param> public void RemoveLog(ElementLog log) { if (log != null) { Messages.Remove(log); } }
/// <summary> /// Adds a warning associated to this model element /// </summary> /// <param name="message"></param> /// <returns></returns> public ElementLog AddWarning(string message) { ElementLog retVal = new ElementLog(ElementLog.LevelEnum.Warning, message); AddElementLog(retVal); return(retVal); }
/// <summary> /// Adds an informative message associated to this model element /// </summary> /// <param name="message"></param> /// <returns></returns> public ElementLog AddInfo(string message) { ElementLog retVal = new ElementLog(ElementLog.LevelEnum.Info, message); AddElementLog(retVal); return(retVal); }
/// <summary> /// Adds an exception associated to this model element /// </summary> /// <param name="exception"></param> /// <returns></returns> public ElementLog AddException(Exception exception) { ElementLog retVal = new ElementLog(ElementLog.LevelEnum.Error, "Exception raised : " + exception.Message + "\n\n" + exception.StackTrace); AddElementLog(retVal); return(retVal); }
/// <summary> /// Adds a new element log attached to this model element /// </summary> /// <param name="log"></param> protected virtual void AddElementLog(ElementLog log) { bool add = true; if (log.Level == ElementLog.LevelEnum.Error) { if (!log.FailedExpectation) // if this is a failed expectation, this is not a model error { ErrorCount += 1; } // System.Diagnostics.Debugger.Break(); } foreach (ElementLog other in Messages) { if (other.CompareTo(log) == 0) { add = false; } } if (add) { Messages.Add(log); } }
/// <summary> /// Adds an error associated to this model element /// </summary> /// <param name="message"></param> /// <param name="failedExpectation"></param> /// <returns></returns> public ElementLog AddError(string message, bool failedExpectation = false) { ElementLog retVal = new ElementLog(ElementLog.LevelEnum.Error, message) { FailedExpectation = failedExpectation }; AddElementLog(retVal); return(retVal); }
/// <summary> /// Adds an error associated to this model element /// </summary> /// <param name="message"></param> /// <returns></returns> public ElementLog AddError(string message) { ElementLog retVal = new ElementLog(ElementLog.LevelEnum.Error, message); if (message.Contains("Failed expectation")) { retVal.FailedExpectation = true; } AddElementLog(retVal); return(retVal); }
/// <summary> /// Adds a new element log attached to this model element /// </summary> /// <param name="log"></param> public virtual void AddElementLog(ElementLog log) { bool add = true; if (log.Level == ElementLog.LevelEnum.Error) { if (!log.FailedExpectation) // if this is a failed expectation, this is not a model error { if (!Errors.ContainsKey(this)) { Errors.Add(this, new List <ElementLog>()); } List <ElementLog> list; if (Errors.TryGetValue(this, out list)) { list.Add(log); } } } foreach (ElementLog other in Messages) { if (other.CompareTo(log) == 0) { add = false; break; } } if (add) { Messages.Add(log); switch (log.Level) { case ElementLog.LevelEnum.Error: UpdateMessageInfo(MessageInfoEnum.Error); break; case ElementLog.LevelEnum.Warning: UpdateMessageInfo(MessageInfoEnum.Warning); break; case ElementLog.LevelEnum.Info: UpdateMessageInfo(MessageInfoEnum.Info); break; } } }