예제 #1
0
        public bool RemoveEntry(SkeletonKeyRoot key)
        {
            if (key.KeyPath.StartsWith(_hive.Root.KeyName) == false)
            {
                var newKeyPath = $"{_hive.Root.KeyName}\\{key.KeyPath}";
                var tempKey    = new SkeletonKeyRoot(newKeyPath, key.AddValues, key.Recursive);
                key = tempKey;
            }

            var intKey = _keys.SingleOrDefault(t => t.KeyPath == key.KeyPath);

            if (intKey == null)
            {
                return(false);
            }

            _keys.Remove(intKey);

            return(true);
        }
예제 #2
0
        /// <summary>
        ///     Adds a SkeletonKey to the SkeletonHive
        /// </summary>
        /// <remarks>Returns true if key is already in list or it is added</remarks>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool AddEntry(SkeletonKeyRoot key)
        {
            var hiveKey = _hive.GetKey(key.KeyPath);

            if (hiveKey == null)
            {
                return(false);
            }

            if (key.KeyPath.StartsWith(_hive.Root.KeyName) == false)
            {
                var newKeyPath = $"{_hive.Root.KeyName}\\{key.KeyPath}";
                var tempKey    = new SkeletonKeyRoot(newKeyPath, key.AddValues, key.Recursive);
                key = tempKey;
            }

            var intKey = _keys.SingleOrDefault(t => t.KeyPath == key.KeyPath);

            if (intKey == null)
            {
                _keys.Add(key);

                if (key.Recursive)
                {
                    // for each subkey in hivekey, create another skr and add it
                    var subs = GetSubkeyNames(hiveKey);

                    foreach (var sub in subs)
                    {
                        var subsk = new SkeletonKeyRoot(sub, true, false);
                        _keys.Add(subsk);
                    }
                }
            }

            return(true);
        }