static bool RegistryToProfileNode(RegistryKey regKey, IProfileNode node, bool recurse = true) { if (node == null) { throw new ArgumentNullException("Argument 'node' cannot be null"); } if (regKey == null) { return(true); } Console.WriteLine($"Converting Registry [{regKey.Name}] => {node.GetType().Name}"); if (String.IsNullOrWhiteSpace(node.Name)) { node.Name = RegKeyToNodeName(regKey); } foreach (string key in regKey.GetValueNames()) { string value = regKey.GetValue(key)?.ToString() ?? ""; IProfileValue pv = sysHlp.SetValueByName(node.ProfileNodeId, key, value); } if (recurse) { foreach (var nodeKey in regKey.GetSubKeyNames()) { Console.WriteLine($"Updating user settings '{nodeKey}'"); if (String.IsNullOrEmpty(nodeKey)) { continue; } RegistryKey subKey = regKey.OpenSubKey(nodeKey); String nodeName = RegKeyToNodeName(subKey); IProfileNode subNode = sysHlp.SubNode(node, nodeName, true); if (!RegistryToProfileNode(subKey, subNode, recurse)) { throw new Exception($"Error loading RegistryKey[{regKey.Name}][{subKey.Name}]"); } } } return(true); }
public int CompareTo(IProfileValue other) => keyComp.Compare(Key, other?.Key);
public bool Equals(IProfileValue other) => keyComp.Equals(Key, other?.Key) && ParentProfileNodeId == other.ParentProfileNodeId;