コード例 #1
0
 public IRegistryNode GetSubNodeByPath(string path, bool createOnNotExist)
 {
     lock (_syncObj)
     {
         if (_subNodes == null && !createOnNotExist)
         {
             return(null);
         }
         if (path.StartsWith("/"))
         {
             throw new ArgumentException("Registry path expression has to be a relative path (no '/' character at the beginning)");
         }
         path = StringUtils.RemoveSuffixIfPresent(path, "/");
         int    i        = path.IndexOf('/');
         string nodeName = i == -1 ? path : path.Substring(0, i);
         CheckSubNodeCollectionPresent();
         IRegistryNode node = _subNodes.ContainsKey(nodeName) ? _subNodes[nodeName] : null;
         if (node == null)
         {
             if (createOnNotExist)
             {
                 node = new RegistryNode(this, nodeName, _syncObj);
                 _subNodes.Add(nodeName, node);
             }
             else
             {
                 return(null);
             }
         }
         return(i == -1 ? node : node.GetSubNodeByPath(RegistryHelper.RemoveRootFromAbsolutePath(path.Substring(i)), createOnNotExist));
     }
 }
コード例 #2
0
 public Registry()
 {
     _rootNode = new RegistryNode(null, string.Empty, _syncObj);
 }
コード例 #3
0
        protected IDictionary <string, object> _items           = null; // lazy initialized

        #endregion

        #region Ctor

        public RegistryNode(RegistryNode parent, string name, object syncObj)
        {
            _parent  = parent;
            _name    = name;
            _syncObj = syncObj;
        }