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

GetVerb() private method

private GetVerb ( [ typeKey, [ commandMapper, [ verbName ) : Verb
typeKey [
commandMapper [
verbName [
return Verb
        private static Verb GetVerb([NotNull] RegistryKey typeKey, [NotNull] CommandMapper commandMapper, [NotNull] string verbName)
        {
            #region Sanity checks
            if (typeKey == null) throw new ArgumentNullException(nameof(typeKey));
            if (string.IsNullOrEmpty(verbName)) throw new ArgumentNullException(nameof(verbName));
            if (commandMapper == null) throw new ArgumentNullException(nameof(commandMapper));
            #endregion

            using (var verbKey = typeKey.OpenSubKey(@"shell\" + verbName))
            {
                if (verbKey == null) return null;

                string description = verbKey.GetValue("", "").ToString();
                string commandLine;
                using (var commandKey = verbKey.OpenSubKey("command"))
                {
                    if (commandKey == null) return null;
                    commandLine = commandKey.GetValue("", "").ToString();
                }

                string additionalArgs;
                var command = commandMapper.GetCommand(commandLine, out additionalArgs);
                if (command == null) return null;
                string commandName = command.Name;

                if (commandName == Command.NameRun) commandName = null;
                var verb = new Verb
                {
                    Name = verbName,
                    Command = commandName,
                    Arguments = additionalArgs
                };
                if (!string.IsNullOrEmpty(description)) verb.Descriptions.Add(description);
                return verb;
            }
        }
    }