Beispiel #1
0
        /// <summary>
        /// Find the node relative to this node instance for
        /// the specified search path.
        /// </summary>
        /// <param name="path">Search path relative to this node.</param>
        /// <returns>Config node instance</returns>
        public virtual AbstractConfigNode Find(string path)
        {
            Preconditions.CheckArgument(path);

            path = ConfigUtils.CheckSearchPath(path, this);
            if (path == ".")
            {
                return(this);
            }
            else if (path.StartsWith(ConfigurationSettings.NODE_SEARCH_SEPERATOR))
            {
                return(Configuration.Find(path));
            }
            path = ConfigUtils.MaskSearchPath(path);
            string[] parts = path.Split(ConfigurationSettings.NODE_SEARCH_SEPERATOR);
            if (parts != null && parts.Length > 0)
            {
                List <string> pList = new List <string>();
                foreach (string part in parts)
                {
                    if (String.IsNullOrWhiteSpace(part))
                    {
                        continue;
                    }
                    string npart = ConfigUtils.UnmaskSearchPath(part);
                    pList.Add(npart);
                }
                ConfigUtils.CheckSearchRoot(pList, Name, Configuration.Settings);
                return(Find(pList, 0));
            }
            return(null);
        }
Beispiel #2
0
 public override AbstractConfigNode Find(string path)
 {
     path = ConfigUtils.CheckSearchPath(path, this);
     if (path == ".")
     {
         return(this);
     }
     else if (path.StartsWith(ConfigurationSettings.NODE_SEARCH_SEPERATOR))
     {
         return(Configuration.Find(path));
     }
     path = ConfigUtils.MaskSearchPath(path);
     string[] parts = path.Split(ConfigurationSettings.NODE_SEARCH_SEPERATOR);
     if (parts != null && parts.Length > 0)
     {
         List <string> pList = new List <string>();
         foreach (string part in parts)
         {
             if (String.IsNullOrWhiteSpace(part))
             {
                 continue;
             }
             string npart = ConfigUtils.UnmaskSearchPath(part);
             pList.Add(npart);
         }
         ConfigUtils.CheckSearchRoot(pList, Name, Configuration.Settings);
         List <AbstractConfigNode> nodes = new List <AbstractConfigNode>();
         foreach (AbstractConfigNode node in GetValues())
         {
             AbstractConfigNode sn = node.Find(pList, 0);
             if (sn != null)
             {
                 nodes.Add(sn);
             }
         }
         if (nodes.Count > 0)
         {
             if (nodes.Count == 1)
             {
                 return(nodes[0]);
             }
             else
             {
                 ConfigSearchResult result = new ConfigSearchResult();
                 result.Configuration = Configuration;
                 result.AddAll(nodes);
                 return(result);
             }
         }
     }
     return(null);
 }