override public bool Match(IMatchTarget matchTarget) { for (int i = 0; i < m_list.Count; i++) { if (m_list[i].Match(matchTarget)) { return(true); } } return(false); }
public override bool Match(IMatchTarget matchTarget) { string name; if (matchTarget is IGetTypeLibElementCommonInfo) { name = (matchTarget as IGetTypeLibElementCommonInfo).Name; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return m_operator.IsTrue(name, m_value); }
public override bool Match(IMatchTarget matchTarget) { string name; if (matchTarget is IGetTypeLibElementCommonInfo) { name = (matchTarget as IGetTypeLibElementCommonInfo).Name; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return(m_operator.IsTrue(name, m_value)); }
public override bool Match(IMatchTarget matchTarget) { TYPEKIND typeKind; if (matchTarget is TypeInfoMatchTarget) { var typeInfoMatchTarget = (TypeInfoMatchTarget) matchTarget; typeKind = typeInfoMatchTarget.TypeKind; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return m_operator.IsTrue(TypeLibUtility.TypeKind2String(typeKind), m_value); }
public override bool Match(IMatchTarget matchTarget) { string nativeSignature; if (matchTarget is SignatureInfoMatchTarget) { var sigInfoMatchTarget = (SignatureInfoMatchTarget) matchTarget; nativeSignature = sigInfoMatchTarget.NativeSignature; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return m_operator.IsTrue("" + nativeSignature, m_value); }
public override bool Match(IMatchTarget matchTarget) { int parameterIndex = 0; if (matchTarget is SignatureInfoMatchTarget) { var sigInfoMatchTarget = (SignatureInfoMatchTarget) matchTarget; parameterIndex = sigInfoMatchTarget.NativeParameterIndex; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return m_operator.IsTrue("" + parameterIndex, m_value); }
public override bool Match(IMatchTarget matchTarget) { string nativeSignature; if (matchTarget is SignatureInfoMatchTarget) { SignatureInfoMatchTarget sigInfoMatchTarget = matchTarget as SignatureInfoMatchTarget; nativeSignature = sigInfoMatchTarget.NativeSignature; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return(m_operator.IsTrue("" + nativeSignature, m_value)); }
public override bool Match(IMatchTarget matchTarget) { string parentName; if (matchTarget is IGetNativeParentName) { IGetNativeParentName getParentNativeName = (IGetNativeParentName) matchTarget; parentName = getParentNativeName.GetNativeParentName(); } else { throw new IGetParentNativeNameUnsupportedException(matchTarget); } return m_operator.IsTrue(parentName, m_value); }
public override bool Match(IMatchTarget matchTarget) { TYPEKIND typeKind; if (matchTarget is TypeInfoMatchTarget) { TypeInfoMatchTarget typeInfoMatchTarget = matchTarget as TypeInfoMatchTarget; typeKind = typeInfoMatchTarget.TypeKind; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return(m_operator.IsTrue(TypeLibUtility.TypeKind2String(typeKind), m_value)); }
public override bool Match(IMatchTarget matchTarget) { int parameterIndex = 0; if (matchTarget is SignatureInfoMatchTarget) { SignatureInfoMatchTarget sigInfoMatchTarget = matchTarget as SignatureInfoMatchTarget; parameterIndex = sigInfoMatchTarget.NativeParameterIndex; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return(m_operator.IsTrue("" + parameterIndex, m_value)); }
public override bool Match(IMatchTarget matchTarget) { Guid guid; if (matchTarget is TypeInfoMatchTarget) { var typeInfoMatchTarget = (TypeInfoMatchTarget) matchTarget; guid = typeInfoMatchTarget.GUID; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return m_operator.IsTrue( guid.ToString().ToUpper(CultureInfo.InvariantCulture), m_value.ToUpper(CultureInfo.InvariantCulture)); }
public override bool Match(IMatchTarget matchTarget) { string parentName; if (matchTarget is IGetNativeParentName) { IGetNativeParentName getParentNativeName = matchTarget as IGetNativeParentName; parentName = getParentNativeName.GetNativeParentName(); } else { throw new IGetParentNativeNameUnsupportedException(matchTarget); } return(m_operator.IsTrue(parentName, m_value)); }
public override bool Match(IMatchTarget matchTarget) { Guid guid; if (matchTarget is TypeInfoMatchTarget) { TypeInfoMatchTarget typeInfoMatchTarget = matchTarget as TypeInfoMatchTarget; guid = typeInfoMatchTarget.GUID; } else { throw new CannotApplyConditionToMatchTargetException(this, matchTarget); } return(m_operator.IsTrue( guid.ToString().ToUpper(CultureInfo.InvariantCulture), m_value.ToUpper(CultureInfo.InvariantCulture))); }
/// <summary> /// Get the all rules if the rule have the same category with the parameter, /// the same ActionDef with the parameter, and the "target" satisified the rule. /// </summary> public List<Rule> GetRule(ICategory category, IActionDef actionDef, IMatchTarget target) { var matchedRuleList = new List<Rule>(); if (category == null) throw new ArgumentNullException(nameof(category)); string key = GetRuleKeyString(category.GetCategoryName()); if (!m_ruleDict.ContainsKey(key)) return matchedRuleList; List<Rule> ruleList = m_ruleDict[key]; foreach (Rule rule in ruleList) { if (rule.Action.GetActionDef() == actionDef && rule.Condition.Match(target)) { matchedRuleList.Add(rule); } } return matchedRuleList; }
/// <summary> /// Get the all rules if the rule have the same category with the parameter, /// the same ActionDef with the parameter, and the "target" satisified the rule. /// </summary> public List <Rule> GetRule(ICategory category, IActionDef actionDef, IMatchTarget target) { List <Rule> matchedRuleList = new List <Rule>(); string key = GetRuleKeyString(category.GetCategoryName()); if (!m_ruleDict.ContainsKey(key)) { return(matchedRuleList); } List <Rule> ruleList = m_ruleDict[key]; foreach (Rule rule in ruleList) { if (rule.Action.GetActionDef() == actionDef && rule.Condition.Match(target)) { matchedRuleList.Add(rule); } } return(matchedRuleList); }
private static NativeNameCondition GetNativeNameCondition(IMatchTarget matchTarget) { NativeNameConditionDef nativeNameConditionDef = NativeNameConditionDef.GetInstance(); if (nativeNameConditionDef.CanApplyToCategory(matchTarget.GetCategory())) { var nativeNameCondition = nativeNameConditionDef.Create() as NativeNameCondition; nativeNameCondition.Operator = EqualOperator.GetInstance(); if (matchTarget is IGetTypeLibElementCommonInfo) { nativeNameCondition.Value = (matchTarget as IGetTypeLibElementCommonInfo).Name; return nativeNameCondition; } else { return null; } } else { return null; } }
public override bool Match(IMatchTarget matchTarget) { return(!m_list[0].Match(matchTarget)); }
public abstract bool Match(IMatchTarget matchTarget);
public CannotApplyConditionToMatchTargetException(ICondition condition, IMatchTarget target) { m_condition = condition; m_target = target; }
public override bool Match(IMatchTarget matchTarget) { return m_list.Any(t => t.Match(matchTarget)); }
public override bool Match(IMatchTarget matchTarget) { return !m_list[0].Match(matchTarget); }
private NativeParentFunctionNameCondition GetNativeParentFunctionNameCondition( IMatchTarget matchTarget) { NativeParentFunctionNameConditionDef nativeParentFunctionNameConditionDef = NativeParentFunctionNameConditionDef.GetInstance(); if (nativeParentFunctionNameConditionDef.CanApplyToCategory(matchTarget.GetCategory()) && matchTarget is IGetNativeParentName) { var nativeParentFunctionNameCondition = nativeParentFunctionNameConditionDef.Create() as NativeParentFunctionNameCondition; nativeParentFunctionNameCondition.Operator = EqualOperator.GetInstance(); nativeParentFunctionNameCondition.Value = (matchTarget as IGetNativeParentName).GetNativeParentName(); return nativeParentFunctionNameCondition; } else { return null; } }
private AndCondition ExtractDefaultConditions(IMatchTarget matchTarget) { ICategory fixedCategory = matchTarget.GetCategory(); var andCondition = AndConditionDef.GetInstance().Create() as AndCondition; if (fixedCategory == SignatureCategory.GetInstance()) { NativeParentFunctionNameCondition nativeParentFunctionNameCondition = GetNativeParentFunctionNameCondition(matchTarget); andCondition.AppendCondition(nativeParentFunctionNameCondition); NativeParameterIndexCondition parameterIndexCondition = GetNativeParameterIndexCondition(matchTarget as SignatureInfoMatchTarget); andCondition.AppendCondition(parameterIndexCondition); } else { // Add conditions. Currently, only the name condition is extracted. NativeNameCondition nativeNameCondition = GetNativeNameCondition(matchTarget); if (nativeNameCondition != null) andCondition.AppendCondition(nativeNameCondition); } return andCondition; }
private void addNewRuleFromHereOperation(IMatchTarget matchTarget) { if (!HasRuleSet()) { MessageBox.Show(Resource.FormatString("Wrn_NoRuleFileToAddRuleTo")); return; } ICategory fixedCategory = matchTarget.GetCategory(); var form = new RuleForm(fixedCategory, "Rule #" + (ruleTreeView.Nodes[0].Nodes.Count + 1)); if (form.ShowDialog() == DialogResult.OK) { IAction action = form.GetAction(); AndCondition andCondition = ExtractDefaultConditions(matchTarget); var newRule = new Rule(fixedCategory, action, andCondition, form.GetRuleName()); var ruleSet = ruleTreeView.Nodes[0].Tag as RuleSet; ruleSet.AddRule(newRule); // Add tree node. TreeNode ruleNode = RuleSet2TreeNodeProcessor.GetRuleTreeNode(newRule); ruleNode.ExpandAll(); ruleTreeView.Nodes[0].Nodes.Add(ruleNode); // set modified SetModified(true); } }
private void addConditionToRuleFileTreeOperation(TreeNode node, IMatchTarget matchTarget) { AndCondition andCondition = ExtractDefaultConditions(matchTarget); TreeNode andConditionNode = RuleSet2TreeNodeProcessor.GetConditionTreeNode( andCondition); andConditionNode.ExpandAll(); if (insertionHighlight.Visible) { TreeNode parentNode = node.Parent; // Insert before node; not Append as the last sun of node. var compositeCondition = parentNode.Tag as AbstractCompositeCondition; compositeCondition.InsertConditionAt(andCondition, node.Index); parentNode.Nodes.Insert(node.Index, andConditionNode); if (!CanAddCondition(parentNode)) parentNode.Nodes.RemoveAt(parentNode.Nodes.Count - 1); } else { // Append as the last sun of node; not Insert before node. var compositeCondition = node.Tag as AbstractCompositeCondition; compositeCondition.AppendCondition(andCondition); node.Nodes.Insert(node.Nodes.Count - 1, andConditionNode); if (!CanAddCondition(node)) node.Nodes.RemoveAt(node.Nodes.Count - 1); } SetModified(true); }
abstract public bool Match(IMatchTarget matchTarget);