コード例 #1
0
ファイル: TestNxEvaluate.cs プロジェクト: killbug2004/WSProf
 public void TestCreateWithSingleParameter()
 {
     string expected = "<Evaluate id=\"7D7EC213-A4E9-4ace-BC40-46A9851FCA0A\"><Parameter name=\"param1\" value=\"val1\" /></Evaluate>";
     NxEvaluate eval = new NxEvaluate("7D7EC213-A4E9-4ace-BC40-46A9851FCA0A", new NxParameter("param1", "val1", false));
     string actual = eval.Create().OuterXml;
     
     Assert.AreEqual(expected, actual);
 }
コード例 #2
0
ファイル: TestNxEvaluate.cs プロジェクト: killbug2004/WSProf
 public void TestCreateWithMultipleParameters()
 {
     string expected = "<Evaluate id=\"7D7EC213-A4E9-4ace-BC40-46A9851FCA0A\"><Parameter name=\"param1\" value=\"val1\" /><Parameter name=\"param2\" value=\"val2\" /></Evaluate>";
     List<NxParameter> parameters = new List<NxParameter>();
     parameters.Add(new NxParameter("param1", "val1", false));
     parameters.Add(new NxParameter("param2", "val2", false));
     
     NxEvaluate eval = new NxEvaluate("7D7EC213-A4E9-4ace-BC40-46A9851FCA0A", parameters);
     string actual = eval.Create().OuterXml;
     
     Assert.AreEqual(expected, actual);
 }
コード例 #3
0
ファイル: NxRoutingSet.cs プロジェクト: killbug2004/WSProf
        private SortedList<int, NxElement> CreateUntrustedRoutingPath()
        {
            SortedList<int, NxElement> untrusted = new SortedList<int, NxElement>();
            IRoutingTable routing = m_policyChannel.Routing;
            if (null == routing)
                return untrusted;

            if ((!routing.HasDefaultSources) && (!routing.HasDefaultDestinations))
                return untrusted;

            Guid unprivDestinationId = routing.DefaultDestination.Identifier;
            Guid unprivSourceId = routing.DefaultSource.Identifier;
            
            IRoutingMatrixCell routingMatrixCell = routing[unprivSourceId, unprivDestinationId];
            if (routingMatrixCell == null)
                return untrusted;

            IActionMatrixCell actionMatrixCell = m_policyChannel.Actions[unprivSourceId, unprivDestinationId];

			string actionSetId = NxUtils.ToNxBreGuid(actionMatrixCell == null ? Guid.NewGuid() : actionMatrixCell.Identifier);

            List<NxParameter> routingParams = FilterRoutingMatrixCell(NxUtils.GetAttributes(routingMatrixCell));
            routingParams.Add(new NxParameter("Name", routingMatrixCell.Name));
            routingParams.Add(new NxParameter("ActionSetId", actionSetId, false));

            NxEvaluate evaluate = new NxEvaluate("RoutingPath", routingParams);

            m_actionSets.Add(new NxActionSet(actionSetId, actionMatrixCell, m_objectWriter, m_resourceManager));

            NxAnd and = new NxAnd();
            and.Append(new NxIsTrue(m_booleanForDummyTrue));


            NxDo routingDo = new NxDo();
            routingDo.Append(evaluate);

            NxControl nxControl = CreateConditionalStatement(routingMatrixCell.Precedence);
            nxControl.Append(and);
            nxControl.Append(routingDo);
            
            untrusted.Add(routingMatrixCell.Precedence, nxControl);
            return untrusted;
        }
コード例 #4
0
        public void WritePolicy(IPolicySet policySet, ICataloguePolicy cataloguePolicy)
        {
            NxParameter catalogueNameParam = new NxParameter("Name", cataloguePolicy);
            List<NxParameter> beforeRuleParams = NxUtils.GetAttributes(cataloguePolicy as IPolicy);
            beforeRuleParams.Add(catalogueNameParam);
            NxEvaluate b4Policy = new NxEvaluate("BeforeRule", beforeRuleParams);
            NxInvokeSet invokeSet = new NxInvokeSet(cataloguePolicy.Identifier.ToString());
            NxEvaluate afterPolicy = new NxEvaluate("AfterRule", catalogueNameParam);

            foreach (NxPolicySet policyset in m_policysets.PolicySets)
            {
                NxSet rulesSet = policyset.GetPolicy(new Guid("{C1C0D5EA-5B82-4607-AE41-D52739AA6AB1}"));
                if (rulesSet == null)
                {
                    rulesSet = new NxSet("C1C0D5EA-5B82-4607-AE41-D52739AA6AB1");
                    rulesSet.Append(b4Policy);
                    rulesSet.Append(invokeSet);
                    rulesSet.Append(afterPolicy);
                    policyset.Policies.Add(rulesSet);
                }
                else
                {
                    rulesSet.Append(b4Policy);
                    rulesSet.Append(invokeSet);
                    rulesSet.Append(afterPolicy);
                }
                policyset.Policies.Add(new NxSet(cataloguePolicy.Identifier.ToString()));
            }
        }