ZeroInstall.Publish.Capture.SnapshotDiff.CollectProtocolAssocsEx C# (CSharp) Method

CollectProtocolAssocsEx() private static method

Collects data about URL protocol handlers indicated by registered application capabilities.
There was an error accessing the registry. Read access to the registry was not permitted.
private static CollectProtocolAssocsEx ( [ capsKey, [ commandMapper, [ capabilities ) : void
capsKey [ A registry key containing capability information for a registered application.
commandMapper [ Provides best-match command-line to mapping.
capabilities [ The capability list to add the collected data to.
return void
        private static void CollectProtocolAssocsEx([NotNull] RegistryKey capsKey, [NotNull] CommandMapper commandMapper, [NotNull] CapabilityList capabilities)
        {
            #region Sanity checks
            if (capsKey == null) throw new ArgumentNullException(nameof(capsKey));
            if (commandMapper == null) throw new ArgumentNullException(nameof(commandMapper));
            if (capabilities == null) throw new ArgumentNullException(nameof(capabilities));
            #endregion

            using (var urlAssocKey = capsKey.OpenSubKey(DesktopIntegration.Windows.AppRegistration.RegSubKeyUrlAssocs))
            {
                if (urlAssocKey == null) return;

                foreach (string protocol in urlAssocKey.GetValueNames())
                {
                    string progID = urlAssocKey.GetValue(protocol, "").ToString();
                    using (var progIDKey = Registry.ClassesRoot.OpenSubKey(progID))
                    {
                        if (progIDKey == null) continue;

                        var prefix = new KnownProtocolPrefix {Value = protocol};
                        var existing = capabilities.GetCapability<UrlProtocol>(progID);
                        if (existing == null)
                        {
                            var capability = new UrlProtocol
                            {
                                ID = progID,
                                Descriptions = {progIDKey.GetValue("", "").ToString()},
                                KnownPrefixes = {prefix}
                            };
                            capability.Verbs.AddRange(GetVerbs(progIDKey, commandMapper));
                            capabilities.Entries.Add(capability);
                        }
                        else existing.KnownPrefixes.Add(prefix);
                    }
                }
            }
        }
        #endregion