Exemplo n.º 1
0
        public RuleSet Parse()
        {
            var ruleSet = new RuleSet();

            XmlNodeList nodeList = m_doc.GetElementsByTagName(RuleFileConstants.RuleElementName);
            foreach (XmlNode node in nodeList)
            {
                // Rule node
                Rule rule = ProcessRuleNode(node);
                ruleSet.AddRule(rule);
            }
            return ruleSet;
        }
Exemplo n.º 2
0
        private void newRuleFileOperation()
        {
            conditionInPlaceEditor.Visible = false;
            if (SaveExistingRuleSet())
            {
                var newRuleSet = new RuleSet();
                TreeNode ruleTreeRoot = RuleSet2TreeNodeProcessor.GetRuleSetTreeNode(newRuleSet);

                ruleTreeView.BeginUpdate();
                ruleTreeView.Nodes.Clear();
                ruleTreeView.Nodes.Add(ruleTreeRoot);
                ruleTreeRoot.Expand();
                ruleTreeView.EndUpdate();

                m_storedRuleFilePath = null;
                SetModified(false);
                UpdateToolBar();
            }
        }
Exemplo n.º 3
0
 private bool CheckRuleSet(RuleSet ruleSet)
 {
     List<Rule> rules = ruleSet.GetAllRules();
     foreach (Rule rule in rules)
     {
         if (rule.Action == null || !rule.Action.IsInitialized)
         {
             MessageBox.Show(Resource.FormatString("Wrn_ActionUninitialized", rule.Name));
             return false;
         }
         if (!CheckCondition(rule.Condition))
         {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 4
0
        private bool RuleEngineResolveRedirection(RuleSet ruleSet, TypeInfo typeInfo,
            out Type convertedType)
        {
            convertedType = null;
            if (ruleSet != null)
            {
                ICategory category = TypeCategory.GetInstance();
                TypeLibTypes.Interop.TYPEKIND typeKind;
                using (TypeAttr attr = typeInfo.GetTypeAttr())
                {
                    typeKind = attr.typekind;
                }
                TypeInfoMatchTarget target = new TypeInfoMatchTarget(typeInfo.GetContainingTypeLib(),
                    typeInfo, typeKind);
                AbstractActionManager actionManager = RuleEngine.GetActionManager();
                List<Rule> resolveToRules = ruleSet.GetRule(
                    category, ResolveToActionDef.GetInstance(), target);
                if (resolveToRules.Count != 0)
                {
                    if (resolveToRules.Count > 1)
                    {
                        Output.WriteWarning(Resource.FormatString("Wrn_RuleMultipleMatch",
                                            ResolveToActionDef.GetInstance().GetActionName()),
                            WarningCode.Wrn_RuleMultipleMatch);
                    }
                    Rule resolveToRule =
                        resolveToRules[resolveToRules.Count - 1];

                    ResolveToAction action =
                        resolveToRule.Action as ResolveToAction;
                    try
                    {
                        Assembly assembly = Assembly.ReflectionOnlyLoad(action.AssemblyName);
                        convertedType = assembly.GetType(action.ManagedTypeFullName);
                        return true;
                    }
                    catch (Exception)
                    {
                        Output.WriteWarning(Resource.FormatString("Wrn_CannotLoadResolveToType",
                                            action.ManagedTypeFullName, action.AssemblyName),
                            WarningCode.Wrn_CannotLoadResolveToType);
                    }
                }
            }
            return false;
        }
 public static TreeNode GetRuleSetTreeNode(RuleSet ruleSet)
 {
     TreeNode ruleSetNode = new TreeNode();
     List<Rule> ruleList = ruleSet.GetAllRules();
     foreach (Rule rule in ruleList)
     {
         TreeNode ruleNode = GetRuleTreeNode(rule);
         ruleSetNode.Nodes.Add(ruleNode);
     }
     ruleSetNode.Tag = ruleSet;
     SetRuleTreeNodeImage(ruleSetNode);
     return ruleSetNode;
 }
Exemplo n.º 6
0
 public RuleFileWriter(RuleSet ruleSet)
 {
     m_ruleSet = ruleSet;
 }