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 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)); } } } }
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; } }