Esempio n. 1
0
        /// <summary>
        /// Returns the information if the specified location can be found in the tree.
        /// If found, the <paramref name="node"/> will be returned.
        /// </summary>
        /// <param name="location">Location to search for. May be absolute or relative.</param>
        /// <param name="node">Node to be returned. If this method returns <c>false</c>, this parameter
        /// is undefined.</param>
        /// <returns><c>true</c>, if the node at the specified <paramref name="location"/> exists,
        /// else <c>false</c>.</returns>
        public bool FindNode(string location, out IConfigurationNode node)
        {
            node = RegistryHelper.IsAbsolutePath(location) ? GetRootNode() : this;
            string[] locEntries = location.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string locEntry in locEntries)
            {
                if (locEntry == ".")
                {
                    continue;
                }
                node = locEntry == ".." ? node.Parent : node.GetSubNodeById(locEntry);
                if (node == null)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
    /// <summary>
    /// Returns the information if the specified location can be found in the tree.
    /// If found, the <paramref name="node"/> will be returned.
    /// </summary>
    /// <param name="location">Location to search for. May be absolute or relative.</param>
    /// <param name="node">Node to be returned. If this method returns <c>false</c>, this parameter
    /// is undefined.</param>
    /// <returns><c>true</c>, if the node at the specified <paramref name="location"/> exists,
    /// else <c>false</c>.</returns>
    public bool FindNode(string location, out IConfigurationNode node)
    {
      node = RegistryHelper.IsAbsolutePath(location) ? GetRootNode() : this;
      string[] locEntries = location.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

      foreach (string locEntry in locEntries)
      {
        if (locEntry == ".")
          continue;
        node = locEntry == ".." ? node.Parent : node.GetSubNodeById(locEntry);
        if (node == null)
          return false;
      }
      return true;
    }