Example #1
0
        public void SearchIndex()
        {
            try
            {
                Configuration configuration = ReadConfiguration();

                Assert.NotNull(configuration);
                string             path = "root/configuration/node_1/ELEMENT_LIST";
                AbstractConfigNode node = configuration.Find(path);
                Assert.NotNull(node);
                Assert.Equal(path, node.GetSearchPath());

                path = "ELEMENT_LIST[3]";
                AbstractConfigNode nnode = node.Find(path);
                Assert.NotNull(nnode);
                Assert.True(nnode.GetType() == typeof(ConfigPathNode));
                LogUtils.Debug(nnode.GetAbsolutePath());

                path = "ELEMENT_LIST[2]/string_2";
                node = node.Find(path);
                Assert.NotNull(node);
                Assert.True(node.GetType() == typeof(ConfigValueNode));
                LogUtils.Debug(node.GetAbsolutePath());
            }
            catch (Exception ex)
            {
                LogUtils.Error(ex);
                throw ex;
            }
        }
Example #2
0
        public void SearchParent()
        {
            try
            {
                Configuration configuration = ReadConfiguration();

                Assert.NotNull(configuration);
                string             path = "root/configuration/node_1/ELEMENT_LIST";
                AbstractConfigNode node = configuration.Find(path);
                Assert.NotNull(node);
                Assert.Equal(path, node.GetSearchPath());
                path = "../node_2/node_3/../#";
                node = node.Find(path);
                Assert.NotNull(node);
                Assert.True(node.GetType() == typeof(ConfigParametersNode));
                LogUtils.Debug(node.GetAbsolutePath());
            }
            catch (Exception ex)
            {
                LogUtils.Error(ex);
                throw ex;
            }
        }
Example #3
0
        public void SearchWildcar()
        {
            try
            {
                Configuration configuration = ReadConfiguration();

                Assert.NotNull(configuration);
                string             path = "root/configuration/node_1/node_2/node_3/*";
                AbstractConfigNode node = configuration.Find(path);
                Assert.NotNull(node);
                Assert.True(node.GetType() == typeof(ConfigSearchResult));
                path = "configuration/node_1/node_2/node_3/*/LONG_VALUE_LIST";
                node = configuration.Find(path);
                Assert.NotNull(node);
                Assert.True(node.GetType() == typeof(ConfigListValueNode));
                Assert.Equal(8, ((ConfigListValueNode)node).Count());
                LogUtils.Debug(node.GetAbsolutePath());
            }
            catch (Exception ex)
            {
                LogUtils.Error(ex);
                throw ex;
            }
        }
Example #4
0
        /// <summary>
        /// Load defined pipelines from the configuration.
        /// </summary>
        /// <param name="config">Configuration Node</param>
        public void Load(AbstractConfigNode config)
        {
            Contract.Requires(config != null);
            AbstractConfigNode ps = null;

            if (config.Name == CONFIG_NODE_PIPELINES)
            {
                ps = config;
            }
            else
            {
                ps = config.Find(CONFIG_NODE_PIPELINES);
            }
            if (ps != null)
            {
                if (ps.GetType() == typeof(ConfigPathNode))
                {
                    ps = ps.Find(CONFIG_NODE_PIPELINE);
                    if (ps != null && ps.GetType() == typeof(ConfigPathNode))
                    {
                        LoadPipeline((ConfigPathNode)ps);
                    }
                    else
                    {
                        LogUtils.Warn(String.Format("No pipeline defined: [path={0}]", config.GetAbsolutePath()));
                    }
                }
                else if (ps.GetType() == typeof(ConfigElementListNode))
                {
                    ConfigElementListNode nodes = (ConfigElementListNode)ps;
                    foreach (ConfigElementNode elem in nodes.GetValues())
                    {
                        if (elem.GetType() == typeof(ConfigPathNode) && elem.Name == CONFIG_NODE_PIPELINE)
                        {
                            LoadPipeline((ConfigPathNode)elem);
                        }
                    }
                }
            }
        }