private IEnumerable <CallHandlerNode> CallHandlerNodesInPolicy(PolicyNode parent) { foreach (CallHandlerNode childNode in GetNodesInChildCollection <CallHandlersCollectionNode, CallHandlerNode>(parent)) { yield return(childNode); } }
private IEnumerable <MatchingRuleNode> MatchingRuleNodesInPolicy(PolicyNode parent) { foreach (MatchingRuleNode childNode in GetNodesInChildCollection <MatchingRuleCollectionNode, MatchingRuleNode>(parent)) { yield return(childNode); } }
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); }
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); }
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); }
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); }