Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
0
 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;
     }
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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);
     }
 }