コード例 #1
0
ファイル: NxPreRoutingSet.cs プロジェクト: killbug2004/WSProf
        private void CreateLDAPEnabledOfflinePreRoutingSet()
        {
            Append(new NxComment("Pre-routing offline enabled"));

            NxObjectLookup isLdapEnabled = new NxObjectLookup(Guid.NewGuid().ToString(), "LDAPAnalyzer", "IsLdapEnabled");

            NxLogic nxLogic = new NxLogic();
            NxIf nxIf = new NxIf();
            NxAnd nxAnd = new NxAnd();
            NxIsTrue nxIsTrue = new NxIsTrue(isLdapEnabled.Identifier);
            NxDo nxDo = new NxDo();

            nxAnd.Append(nxIsTrue);
            nxIf.Append(nxAnd);
            nxDo.Append(new NxComment("Online routing"));
            nxDo.Append(new NxEvaluate("RuleFired", BuildRuleFiredParameters()));
            nxIf.Append(nxDo);
            nxLogic.Append(nxIf);

            NxElse nxElse = new NxElse();
            nxElse.Append(new NxComment("Offline routing"));
            nxElse.Append(new NxEvaluate("RuleFired", BuildOfflineRuleFiredParameters()));
            nxLogic.Append(nxElse);
            
            Append(isLdapEnabled);
            AppendLogic(nxLogic);
        }
コード例 #2
0
ファイル: NxRoutingSet.cs プロジェクト: killbug2004/WSProf
        public NxSet CreateRoutingTable()
        {
            NxLogic logic = new NxLogic();
            SortedList<int, NxElement> routingPath = CreateRoutingPath();

            foreach (KeyValuePair<string, string> kvp in m_memberOfGroupLookups.Keys)
            {
                m_routingSet.Append(m_memberOfGroupLookups[kvp]);
            }

            foreach (KeyValuePair<string, string> kvp in m_notMemberOfGroupLookups.Keys)
            {
                m_routingSet.Append(m_notMemberOfGroupLookups[kvp]);
            }

            foreach (NxObjectLookup objectLookup in m_isEnabledLookups)
            {
                m_routingSet.Append(objectLookup);
            }

            foreach (KeyValuePair<int, NxElement> set in routingPath)
            {
                logic.Append(set.Value);
            }

            if (logic.Count > 0) // If there is no routing don't add an empty logic block.
                m_routingSet.AppendLogic(logic);

            return m_routingSet;
        }
コード例 #3
0
        public void WriteCondition(IPolicySet policySet, IPolicyObject parent, ICondition condition, ConditionLogic cdnlogic)
        {
            NxLogic logic = new NxLogic();
            NxIf iF = new NxIf();
            NxOperator conditionTest = null;
            if (condition.IsNegated)
                conditionTest = new NxNot();
            else
                conditionTest = new NxAnd();

            IDataElement lhs = condition.DataLeft;
            IDataElement rhs = condition.DataRight;

            WriteDataElement(lhs);
            WriteDataElement(rhs);

            string incrementId = Guid.NewGuid().ToString();
            List<NxParameter> parameters = NxUtils.GetAttributes(condition);

            NxSet currentPolicy = m_policysets.PolicySets[0].CurrentPolicy;

            string lhsId = lhs.Identifier.ToString();
            string rhsId = rhs.Identifier.ToString();
            if (condition.Class == "IDataLengthComparer")
            {
                if ((lhs.Type == DataType.Object) || (NxUtils.IsArray(lhs.Type)))
                {
                    lhsId = Guid.NewGuid().ToString();
                    foreach (NxPolicySet policyset in m_policysets.PolicySets)
                    {
                        policyset.CurrentPolicy.Append(new NxObjectLookup(lhsId, lhs.Identifier.ToString(), "Length"));
                    }
                    parameters.Add(new NxParameter("Properties", lhs.Identifier.ToString(), true));
                }

                if ((rhs.Type == DataType.Object) || (NxUtils.IsArray(rhs.Type)))
                {
                    rhsId = Guid.NewGuid().ToString();
                    foreach (NxPolicySet policyset in m_policysets.PolicySets)
                    {
                        policyset.CurrentPolicy.Append(new NxObjectLookup(rhsId, rhs.Identifier.ToString(), "Length"));
                    }
                    parameters.Add(new NxParameter("Properties", rhs.Identifier.ToString(), true));
                }
            }
            conditionTest.Append(lhsId, rhsId, condition.Operator);

            NxDo dO = new NxDo();

            foreach (NxPolicySet policyset in m_policysets.PolicySets)
            {
                policyset.AppendIncrementer(new NxIncrement(incrementId));
                policyset.AppendIncrementer(new NxIncrementStep(incrementId));
            }
           
            dO.Append(new NxIncrementStep(incrementId));
            bool ignored = NxUtils.IsIgnored(condition);
            iF.Append(conditionTest);
            iF.Append(dO);
            logic.Append(iF);
            if (!ignored)
            {
                parameters.Add(new NxParameter("Name", condition));
                dO.Append(new NxEvaluate("ConditionLineFired", new List<NxParameter>(parameters.ToArray())));
                NxElse eLse = new NxElse();
                eLse.Append(new NxEvaluate("ConditionLinePassed", new List<NxParameter>(parameters.ToArray())));
                logic.Append(eLse);
            }
            foreach (NxPolicySet policyset in m_policysets.PolicySets)
            {
                policyset.Policies[policyset.Policies.Count - 1].AppendLogic(logic);
                policyset.Policies[policyset.Policies.Count - 1].AppendIncrementId(incrementId, parent.Identifier, cdnlogic); //IConditionGroup
            }
        }
コード例 #4
0
ファイル: NxConditionSet.cs プロジェクト: killbug2004/WSProf
        private NxLogic BuildConditionGroupLogicBlock()
        {
            NxLogic ruleLogic = new NxLogic();
            NxIf ruleIf = new NxIf();
            NxDo ruleDo = new NxDo();
            List<Guid> conditionGroups = GetListOfConditionGroups();

            if (conditionGroups.Count == 0)
                return null;

            List<NxOperator> conditionGroupList = new List<NxOperator>();
            foreach (Guid condtionGroup in conditionGroups)
            {
                List<IncrementConditionGroup> conditionGroup = GetConditionGroup(condtionGroup);
                if (conditionGroup.Count == 0)
                    continue;

                NxOperator nxAnd = new NxAnd();
                foreach (IncrementConditionGroup icg in conditionGroup)
                {
                    nxAnd.Append(icg.IncrementIdentifier, "0i", OperatorType.GreaterThan);
                }
                conditionGroupList.Add(nxAnd);
            }

            ConditionLogic conditionLogic = GetConditionGroup(conditionGroups[0])[0].ConditionLogic;

            NxOperator nxOldOp = null;
            for(int i = 0; i < conditionGroupList.Count; ++i)
            {
                NxOperator nxOp = null;
                switch (conditionLogic)
                {
                    case ConditionLogic.AND:
                        nxOp = new NxAnd();
                        break;
                    case ConditionLogic.OR:
                        nxOp = new NxOr();
                        break;
                    case ConditionLogic.NOT:
                        break;
                }
                nxOp.Append(conditionGroupList[i]);

                if (i == 0)
                {
                    ruleIf.Append(nxOp);
                    nxOldOp = nxOp;
                }
                else
                {
                    nxOldOp.Append(nxOp);
                }
            }
            ruleDo.Append(new NxComment("Pre-routing set id"));
            ruleDo.Append(new NxInvokeSet(m_PreRoutingId));
            ruleIf.Append(ruleDo);
            ruleLogic.Append(ruleIf);
            return ruleLogic;
        }