Example #1
0
 private static bool ValidateChannelActions(string policyName, IActionMatrix actionMatrix, PolicySetValidator.AddViolationMessageHandler AddMessage)
 {
     bool valid = false;
     foreach (KeyValuePair<KeyValuePair<Guid, Guid>, IActionMatrixCell> cellPair in actionMatrix)
     {
         if (ValidateActionConditionGroups(policyName, cellPair.Value.ActionConditionGroups, AddMessage))
             valid = true;
     }
     return valid;
 }
        private void WriteActionExceptionCell(XmlNode xmlActionMatrixNode, IActionMatrix actionMatrix)
        {
            if ((null == xmlActionMatrixNode) || (null == actionMatrix) || !actionMatrix.HasActionExceptionHandler)
                return;

            IActionMatrixCell actionExceptionCell = actionMatrix.ActionExceptionHandler;
            XmlNode xmlActionExceptionCellNode = m_xmlDocument.CreateElement("ActionException");
            xmlActionMatrixNode.AppendChild(xmlActionExceptionCellNode);
            XmlHelpers.AddReadOnlyAttribute(xmlActionExceptionCellNode, actionMatrix.ReadOnly);

            WriteActionMatrixCell(xmlActionExceptionCellNode, actionExceptionCell);
        }
        private void WriteOfflineCell(XmlNode xmlActionMatrixNode, IActionMatrix actionMatrix)
        {
            if ((null == xmlActionMatrixNode) || (null == actionMatrix) || !actionMatrix.HasOffline)
                return;

            IActionMatrixCell offlineActionMatrixCell = actionMatrix.Offline;
            XmlNode xmlOfflineActionCellNode = m_xmlDocument.CreateElement("Offline");
            xmlActionMatrixNode.AppendChild(xmlOfflineActionCellNode);
            XmlHelpers.AddReadOnlyAttribute(xmlOfflineActionCellNode, actionMatrix.ReadOnly);

            WriteActionMatrixCell(xmlOfflineActionCellNode, offlineActionMatrixCell);
        }
Example #4
0
        private void CopyChannel(PolicyChannel rhs, bool readOnly, bool createNewId)
        {
            m_policySetObserver = rhs.m_policySetObserver;
            if (null != rhs.Routing)
            {
                m_routing = RoutingTableFactory.Instance.Copy(rhs.Routing, readOnly, createNewId);
                SetRoutingTableObserver();
            }

            if (null != rhs.Actions)
            {
                m_actions = (rhs.Actions as ActionMatrix).DeepCopy(readOnly, createNewId) as IActionMatrix;
                SetActionMatrixObserver();
            }
        }
        private void WriteActionCells(XmlNode xmlActionMatrixNode, IActionMatrix actionMatrix)
        {
            if (null == actionMatrix)
                return;

            foreach (KeyValuePair<KeyValuePair<Guid, Guid>, IActionMatrixCell> actionMatrixCellPair in actionMatrix)
            {
                IActionMatrixCell actionMatrixCell = actionMatrixCellPair.Value as IActionMatrixCell;
                XmlNode xmlActionCellNode = m_xmlDocument.CreateElement("ActionMatrixCell");
                xmlActionMatrixNode.AppendChild(xmlActionCellNode);
                XmlHelpers.AddAttribute(xmlActionCellNode, "SourceRoutingItemCollectionId", actionMatrixCellPair.Key.Key.ToString("B", CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture));
                XmlHelpers.AddAttribute(xmlActionCellNode, "DestinationRoutingItemCollectionId", actionMatrixCellPair.Key.Value.ToString("B", CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture));
                XmlHelpers.AddReadOnlyAttribute(xmlActionCellNode, actionMatrix.ReadOnly);
                WriteActionMatrixCell(xmlActionCellNode, actionMatrixCell);
            }
        }
Example #6
0
 public static void RemoveCellFromActionMatrix(IActionMatrix actionMatrix, 
     IRoutingItemCollection senderAddressCollection, IRoutingItemCollection recipientAddressCollection)
 {
     actionMatrix.Remove(senderAddressCollection, recipientAddressCollection);
 }
Example #7
0
 public static void AddCellToActionMatrix(IActionMatrix actionMatrix,
     IRoutingItemCollection senderAddressCollection, IRoutingItemCollection recipientAddressCollection)
 {
     if (!actionMatrix.HasCell(senderAddressCollection, recipientAddressCollection))
     {
         actionMatrix[senderAddressCollection, recipientAddressCollection] =
             ActionMatrixCellFactory(senderAddressCollection, recipientAddressCollection);
     }
 }
 public XmlPolicyActionsWriter(XmlNode xmlParentNode, IActionMatrix actions)
     : base(xmlParentNode)
 {
     m_actions = actions;
 }
 private void ValidateActionMatrix(IActionMatrix actionMatrix, int expectedCellCount)
 {
     Assert.IsTrue(actionMatrix.ReadOnly, "Expected the action matrix to be read only");
     Assert.AreEqual(expectedCellCount, actionMatrix.CellCount, "Expected the action matrix have four cells");
     foreach (KeyValuePair<KeyValuePair<Guid, Guid>, IActionMatrixCell> actionMatrixCellPair in actionMatrix)
     {
         IActionMatrixCell actionMatrixCell = actionMatrixCellPair.Value;
         Assert.IsNotNull(actionMatrixCell);
         ValidateActionMatrixCell(actionMatrixCell);
     }
 }
Example #10
0
        private void AssignExceptionIdToActions(IActionMatrix actionMatrix, IActionMatrixCell iamc)
        {
            const string exceptionHandlerPropertyName = "ExceptionHandler";
            IPolicyObjectCollection<IAction> exceptionActions = ExtractTopLevelActions(iamc);
            if ((null == exceptionActions) || (0 == exceptionActions.Count))
                return;

            // We will only use the first exception action - there should be only one anyway
            IAction exceptionAction = exceptionActions[0];

            exceptionAction[exceptionHandlerPropertyName].Value = exceptionAction.Identifier.ToString("B").ToUpper(CultureInfo.InvariantCulture);

            foreach (KeyValuePair<KeyValuePair<Guid, Guid>, IActionMatrixCell> matrixCellPair in actionMatrix)
            {
                IPolicyObjectCollection<IAction> actions = ExtractTopLevelActions(matrixCellPair.Value);
                foreach (IAction action in actions)
                {
                    action[exceptionHandlerPropertyName].Value = exceptionAction[exceptionHandlerPropertyName].Value;
                }
            }
        }