private void CompareValues(RegistryValueSnapshotCollection lhs, RegistryValueSnapshotCollection rhs,
                                   ICollection <ChangeResult> results)
        {
            if (lhs != null && rhs != null)
            {
                this.CompareValues(lhs, rhs, ChangeType.Insertion, results);

                this.CompareValues(rhs, lhs, ChangeType.Deletion, results);
            }
        }
        private void FillValues(RegistryKeySnapshot snapshot, RegistryKey key)
        {
            if (key.ValueCount != 0)
            {
                RegistryValueSnapshotCollection children;
                string[] names;

                children = new RegistryValueSnapshotCollection(snapshot);

                try
                {
                    names = key.GetValueNames();
                }
                catch (IOException)
                {
                    // system error, saw this in latest Windows 10
                    // when trying to scan HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\CreativeEventCache\SubscribedContent-314559
                    names = _emptyArray;
                }

                for (int i = 0; i < names.Length; i++)
                {
                    string            name;
                    string            value;
                    RegistryValueKind type;
                    object            rawValue;

                    name     = names[i];
                    type     = key.GetValueKind(name);
                    rawValue = this.GetValue(key, type, name);
                    value    = this.TransformRawValue(type, rawValue);

                    children.Add(new RegistryValueSnapshot(name, value, type));
                }

                snapshot.Values = children;
            }
        }
        private void FillValues(RegistryKeySnapshot snapshot, RegistryKey key)
        {
            if (key.ValueCount != 0)
            {
                RegistryValueSnapshotCollection children;

                children = new RegistryValueSnapshotCollection(snapshot);

                foreach (string name in key.GetValueNames())
                {
                    string            value;
                    RegistryValueKind type;
                    object            rawValue;

                    type     = key.GetValueKind(name);
                    rawValue = this.GetValue(key, type, name);
                    value    = this.TransformRawValue(type, rawValue);

                    children.Add(new RegistryValueSnapshot(name, value, type));
                }

                snapshot.Values = children;
            }
        }
        private void CompareValues(RegistryValueSnapshotCollection lhs, RegistryValueSnapshotCollection rhs, ChangeType type,
                                   ICollection <ChangeResult> results)
        {
            foreach (RegistryValueSnapshot value in lhs)
            {
                string name;
                RegistryValueSnapshot compare;

                name = value.Name;

                if (rhs == null || !rhs.TryGetValue(name, out compare))
                {
                    results.Add(new ChangeResult(type, lhs.Parent.FullPath, value.Name, value.Type, value.Value, null));
                }
                else if (type == ChangeType.Insertion)
                {
                    if (!string.Equals(value.Value, compare.Value, StringComparison.Ordinal) || value.Type != compare.Type)
                    {
                        results.Add(new ChangeResult(ChangeType.Modification, lhs.Parent.FullPath, value.Name, value.Type,
                                                     compare.Value, value.Value));
                    }
                }
            }
        }