Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 7
0
        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);
 }
Ejemplo n.º 9
0
        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));
        }
Ejemplo n.º 10
0
        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));
        }
Ejemplo n.º 11
0
 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));
        }
Ejemplo n.º 13
0
        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)));
        }
Ejemplo n.º 14
0
 /// <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;
 }
Ejemplo n.º 15
0
        /// <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);
        }
Ejemplo n.º 16
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;
     }
 }
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 20
0
 public override bool Match(IMatchTarget matchTarget)
 {
     return m_list.Any(t => t.Match(matchTarget));
 }
Ejemplo n.º 21
0
 public override bool Match(IMatchTarget matchTarget)
 {
     return !m_list[0].Match(matchTarget);
 }
 public CannotApplyConditionToMatchTargetException(ICondition condition, IMatchTarget target)
 {
     m_condition = condition;
     m_target = target;
 }
Ejemplo n.º 23
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;
     }
 }
Ejemplo n.º 24
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;
 }
Ejemplo n.º 25
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);
     }
 }
Ejemplo n.º 26
0
 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);
 }
Ejemplo n.º 27
0
 abstract public bool Match(IMatchTarget matchTarget);