コード例 #1
0
 private IEnumerable <CallHandlerNode> CallHandlerNodesInPolicy(PolicyNode parent)
 {
     foreach (CallHandlerNode childNode in GetNodesInChildCollection <CallHandlersCollectionNode, CallHandlerNode>(parent))
     {
         yield return(childNode);
     }
 }
コード例 #2
0
 private IEnumerable <MatchingRuleNode> MatchingRuleNodesInPolicy(PolicyNode parent)
 {
     foreach (MatchingRuleNode childNode in GetNodesInChildCollection <MatchingRuleCollectionNode, MatchingRuleNode>(parent))
     {
         yield return(childNode);
     }
 }
コード例 #3
0
        public PolicyInjectionSettingsNode Build()
        {
            PolicyInjectionSettingsNode node           = new PolicyInjectionSettingsNode();
            InjectorCollectionNode      injectorsNode  = new InjectorCollectionNode();
            PolicyCollectionNode        collectionNode = new PolicyCollectionNode();

            node.AddNode(injectorsNode);
            node.AddNode(collectionNode);

            foreach (InjectorData injectorData in settings.Injectors)
            {
                AddInjector(injectorData, injectorsNode);
            }
            foreach (PolicyData policyData in settings.Policies)
            {
                PolicyNode policyNode = new PolicyNode(policyData);

                AddMatchingRules(policyData, policyNode);

                AddHandlers(policyData, policyNode);

                collectionNode.AddNode(policyNode);
            }

            return(node);
        }
コード例 #4
0
        private void AddMatchingRules(PolicyData policyData, PolicyNode policyNode)
        {
            MatchingRuleCollectionNode matchingRuleCollectionNode = new MatchingRuleCollectionNode();

            foreach (MatchingRuleData matchingRule in policyData.MatchingRules)
            {
                ConfigurationNode matchingRuleNode = base.NodeCreationService.CreateNodeByDataType(matchingRule.GetType(), new object[] { matchingRule });
                if (matchingRuleNode == null)
                {
                    base.LogNodeMapError(matchingRuleCollectionNode, matchingRule.GetType());
                    break;
                }
                matchingRuleCollectionNode.AddNode(matchingRuleNode);
            }
            policyNode.AddNode(matchingRuleCollectionNode);
        }
コード例 #5
0
        private PolicyData BuildPolicyData(PolicyNode policyNode)
        {
            PolicyData policyData = new PolicyData(policyNode.Name);

            foreach (MatchingRuleNode ruleNode in MatchingRuleNodesInPolicy(policyNode))
            {
                MatchingRuleData ruleData = ruleNode.GetConfigurationData();
                policyData.MatchingRules.Add(ruleData);
            }

            foreach (CallHandlerNode handlerNode in CallHandlerNodesInPolicy(policyNode))
            {
                CallHandlerData handlerData = handlerNode.CreateCallHandlerData();
                policyData.Handlers.Add(handlerData);
            }
            return(policyData);
        }
コード例 #6
0
        private void AddHandlers(PolicyData policyData, PolicyNode policyNode)
        {
            CallHandlersCollectionNode callHandlersCollectionNode = new CallHandlersCollectionNode();

            foreach (CallHandlerData handler in policyData.Handlers)
            {
                ConfigurationNode handlerNode = base.NodeCreationService.CreateNodeByDataType(handler.GetType(), new object[] { handler });
                if (handlerNode == null)
                {
                    base.LogNodeMapError(callHandlersCollectionNode, handler.GetType());
                    break;
                }
                callHandlersCollectionNode.AddNode(handlerNode);

                CallHandlerNode typedHandlerNode = handlerNode as CallHandlerNode;
                if (typedHandlerNode != null)
                {
                    typedHandlerNode.ResolveNodeReferences(configurationHierarchy);
                }
            }
            policyNode.AddNode(callHandlersCollectionNode);
        }