/// <summary>分析命名空间</summary> /// <param name="code"></param> /// <returns></returns> String ParseNameSpace(String code) { var sb = new StringBuilder(); var ss = code.Split(new String[] { Environment.NewLine }, StringSplitOptions.None); foreach (var item in ss) { // 提取命名空间 if (!String.IsNullOrEmpty(item)) { var line = item.Trim(); if (line.StartsWith("using ") && line.EndsWith(";")) { var len = "using ".Length; line = line.Substring(len, line.Length - len - 1); if (!NameSpaces.Contains(line)) { NameSpaces.Add(line); } // 不能截断命名空间,否则报错行号会出错 sb.AppendLine(); continue; } } sb.AppendLine(item); } return(sb.ToString().Trim()); }
/// <summary> /// Indicates that an event should be shown /// </summary> /// <param name="evt"></param> /// <returns></returns> public bool VisibleEvent(ModelEvent evt) { bool retVal = true; // Check event type retVal = retVal && (!(evt is Expect) || Expect); retVal = retVal && (!(evt is RuleFired) || RuleFired); retVal = retVal && (!(evt is VariableUpdate) || VariableUpdate); // Check event namespace if (retVal) { if (evt.NameSpace != null) { retVal = NameSpaces.Contains(evt.NameSpace); } } // Keep messages that match the regular expression if (!Utils.Utils.isEmpty(RegExp)) { Regex regularExpression = new Regex(RegExp); retVal = retVal || regularExpression.IsMatch(evt.Message); } // Ignore those internal events retVal = retVal && (!(evt is ExpectationStateChange)); retVal = retVal && (!(evt is SubStepActivated)); return(retVal); }
/// <summary> /// Indicates that an event should be shown /// </summary> /// <param name="evt"></param> /// <returns></returns> public bool VisibleEvent(ModelEvent evt) { bool retVal = true; // Check event type // ReSharper disable once ConditionIsAlwaysTrueOrFalse retVal = retVal && (!(evt is Expect) || Expect); retVal = retVal && (!(evt is RuleFired) || RuleFired); // Ignore the following internal events retVal = retVal && (!(evt is ExpectationStateChange)); retVal = retVal && (!(evt is SubStepActivated)); if (retVal) { // Checks the variable update VariableUpdate variableUpdate = evt as VariableUpdate; if (variableUpdate != null) { if (VariableUpdate) { // Do not filter out variables updates for which the rule is not available // because these updates are related to test steps or external input (using EFS service) if (variableUpdate.Action.RuleCondition != null) { retVal = false; foreach (Variable variable in Variables) { retVal = variableUpdate.Changes.ImpactVariable(variable); if (retVal) { break; } } } } else { retVal = false; } } else { // Check event namespace if (evt.NameSpace != null) { retVal = NameSpaces.Contains(evt.NameSpace); } } } // Keep messages that match the regular expression if (!Util.isEmpty(RegExp)) { Regex regularExpression = new Regex(RegExp); retVal = retVal || regularExpression.IsMatch(evt.Message); } return(retVal); }
public TypeCreator AddNameSpace(string name) { if (!NameSpaces.Contains(name)) { NameSpaces.Add(name); } return(this); }
public bool IsExcluded(Type type) { return(Types.Contains(type) || NameSpaces.Contains(type.Namespace)); }