Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the configuration class using the XmlNode specified.
        /// </summary>
        /// <param name="configNode">The XmlNode for the configuration section.</param>
        public ConfigurationRoot(XmlNode configNode)
        {
            if (configNode == null)
            {
                throw new ArgumentNullException("configNode");
            }

            // Load all attribute repositories
            XmlNodeList nodeList = configNode.SelectNodes("./attributeRepositories/repository");

            foreach (XmlNode node in nodeList)
            {
                AttributeRepositoryConfig repConfig = new AttributeRepositoryConfig(node);

                IAttributeRepository rep = (IAttributeRepository)Activator.CreateInstance(repConfig.Type);
                rep.Init(repConfig.XmlNode);

                _attributeRepositories.Add(rep);
            }

            // Load all policy repositories
            nodeList = configNode.SelectNodes("./policyRepositories/repository");
            foreach (XmlNode node in nodeList)
            {
                PolicyRepositoryConfig policyConfig = new PolicyRepositoryConfig(node);

                IPolicyRepository rep = (IPolicyRepository)Activator.CreateInstance(policyConfig.Type);
                rep.Init(policyConfig.XmlNode);

                _policyRepositories.Add(rep);
            }

            // Load all function repositories
            nodeList = configNode.SelectNodes("./functionRepositories/repository");
            foreach (XmlNode node in nodeList)
            {
                FunctionRepositoryConfig functionConfig = new FunctionRepositoryConfig(node);

                IFunctionRepository rep = (IFunctionRepository)Activator.CreateInstance(functionConfig.Type);
                rep.Init(functionConfig.XmlNode);

                _functionRepositories.Add(rep);
            }

            // Load all dataType repositories
            nodeList = configNode.SelectNodes("./dataTypeRepositories/repository");
            foreach (XmlNode node in nodeList)
            {
                DataTypeRepositoryConfig dataTypeConfig = new DataTypeRepositoryConfig(node);

                IDataTypeRepository rep = (IDataTypeRepository)Activator.CreateInstance(dataTypeConfig.Type);
                rep.Init(dataTypeConfig.XmlNode);

                _dataTypeRepositories.Add(rep);
            }

            // Load all rule combinig algorothm repositories
            nodeList = configNode.SelectNodes("./ruleCombiningAlgorithmRepositories/repository");
            foreach (XmlNode node in nodeList)
            {
                RuleCombiningAlgorithmRepository ruleCAConfig = new RuleCombiningAlgorithmRepository(node);

                IRuleCombiningAlgorithmRepository rep = (IRuleCombiningAlgorithmRepository)Activator.CreateInstance(ruleCAConfig.Type);
                rep.Init(ruleCAConfig.XmlNode);

                _ruleCombiningRepositories.Add(rep);
            }

            // Load all policy combinig algorothm repositories
            nodeList = configNode.SelectNodes("./policyCombiningAlgorithmRepositories/repository");
            foreach (XmlNode node in nodeList)
            {
                PolicyCombiningAlgorithmRepository policyCAConfig = new PolicyCombiningAlgorithmRepository(node);

                IPolicyCombiningAlgorithmRepository rep = (IPolicyCombiningAlgorithmRepository)Activator.CreateInstance(policyCAConfig.Type);
                rep.Init(policyCAConfig.XmlNode);

                _policyCombiningRepositories.Add(rep);
            }

            // Load all rule combinig algorothm repositories
            nodeList = configNode.SelectNodes("./ruleCombiningAlgorithmRepositories/repository");
            foreach (XmlNode node in nodeList)
            {
                _ruleCombiningRepositories.Add(new RuleCombiningAlgorithmRepository(node));
            }
        }