示例#1
0
        private void AddKeys(RegistryKeySnapshotCollection keys, TreeNodeCollection container)
        {
            container.Clear();

            foreach (RegistryKeySnapshot key in keys)
            {
                this.AddKey(key, container);
            }
        }
        private void CompareKeys(RegistryKeySnapshotCollection lhs, RegistryKeySnapshotCollection rhs,
                             ICollection<ChangeResult> results)
        {
            if (lhs != null && rhs != null)
              {
            this.CompareKeys(lhs, rhs, ChangeType.Insertion, results);

            this.CompareKeys(rhs, lhs, ChangeType.Deletion, results);
              }
        }
        private void CompareKeys(RegistryKeySnapshotCollection lhs, RegistryKeySnapshotCollection rhs, ChangeType type,
                             ICollection<ChangeResult> results)
        {
            foreach (RegistryKeySnapshot key in lhs)
              {
            string name;
            RegistryKeySnapshot compare;

            name = key.Name;

            if (rhs == null || !rhs.TryGetValue(name, out compare))
            {
              results.Add(new ChangeResult(type, key.FullPath));
            }
            else if (type == ChangeType.Insertion)
            {
              this.CompareKeys(key, compare, results);
            }
              }
        }
        private void AddKeys(RegistryKeySnapshotCollection keys, TreeNodeCollection container)
        {
            container.Clear();

              foreach (RegistryKeySnapshot key in keys)
              {
            this.AddKey(key, container);
              }
        }
        private void FillKeys(RegistryKeySnapshot snapshot, RegistryKey key)
        {
            if (key.SubKeyCount != 0)
              {
            RegistryKeySnapshotCollection children;

            children = new RegistryKeySnapshotCollection(snapshot);

            // ReSharper disable once LoopCanBePartlyConvertedToQuery
            foreach (string name in key.GetSubKeyNames())
            {
              // HACK: Although I thought key names were unique, clearly I was wrong as the scan used to crash on
              // HKEY_LOCAL_MACHINE\SOFTWARE\Yamaha APO which appears at least twice on my system, although RegEdit
              // only shows a single copy

              if (!children.Contains(this.GetShortName(name)))
              {
            RegistryKey subKey;

            subKey = this.GetSubKey(key, name);

            if (subKey != null)
            {
              RegistryKeySnapshot childSnapshot;

              childSnapshot = this.TakeSnapshot(subKey);

              children.Add(childSnapshot);
            }
              }
            }

            snapshot.SubKeys = children;
              }
        }