protected override async Task <int> Validate()
        {
            var baseResult = await base.Validate().ConfigureAwait(false);

            if (baseResult != StandardExitCodes.ErrorSuccess)
            {
                return(baseResult);
            }

            if (!Enum.TryParse <ValueType>(this.Verb.ValueType, true, out var parsed))
            {
                await this.Console.WriteError($"Value type '{this.Verb.ValueType}' could not be parsed.").ConfigureAwait(false);

                return(StandardExitCodes.ErrorParameter);
            }

            try
            {
                switch (parsed)
                {
                case ValueType.String:
                case ValueType.Expandable:
                case ValueType.Default:
                case ValueType.None:
                    RawRegistryValueConverter.GetStringFromString(this.Verb.Value);
                    break;

                case ValueType.DWord:
                    RawRegistryValueConverter.GetDWordFromString(this.Verb.Value);
                    break;

                case ValueType.QWord:
                    RawRegistryValueConverter.GetQWordFromString(this.Verb.Value);
                    break;

                case ValueType.Multi:
                    RawRegistryValueConverter.GetMultiValueFromString(this.Verb.Value);
                    break;

                case ValueType.Binary:
                    RawRegistryValueConverter.GetByteArrayFromString(this.Verb.Value);
                    break;

                default:
                    await this.Console.WriteError($"The value type '{this.Verb.ValueType}' is not supported.").ConfigureAwait(false);

                    return(StandardExitCodes.ErrorParameter);
                }
            }
            catch (ArgumentException e)
            {
                await this.Console.WriteError(e.Message).ConfigureAwait(false);

                return(StandardExitCodes.ErrorParameter);
            }

            return(StandardExitCodes.ErrorSuccess);
        }
        protected override async Task <int> ExecuteOnExtractedPackage(string directoryPath)
        {
            var command = new SetRegistryValue
            {
                RegistryKey       = this.Verb.RegistryKey,
                RegistryValueName = this.Verb.RegistryValueName,
                ValueType         = Enum.Parse <ValueType>(this.Verb.ValueType, true)
            };

            switch (command.ValueType)
            {
            case ValueType.None:
            case ValueType.Default:
            case ValueType.String:
            case ValueType.Expandable:
                command.Value = RawRegistryValueConverter.GetStringFromString(this.Verb.Value);
                break;

            case ValueType.DWord:
                unchecked
                {
                    // Note: this conversion is by-design because .NET API for registry expects signed values.
                    command.Value = (int)RawRegistryValueConverter.GetDWordFromString(this.Verb.Value);
                    break;
                }

            case ValueType.QWord:
                unchecked
                {
                    // Note: this conversion is by-design because .NET API for registry expects signed values.
                    command.Value = (long)RawRegistryValueConverter.GetQWordFromString(this.Verb.Value);
                    break;
                }

            case ValueType.Multi:
                command.Value = RawRegistryValueConverter.GetMultiValueFromString(this.Verb.Value);
                break;

            case ValueType.Binary:
                command.Value = RawRegistryValueConverter.GetByteArrayFromString(this.Verb.Value);
                break;

            default:
                return(StandardExitCodes.ErrorGeneric);
            }

            var target = RegistryPathConverter.ToCanonicalRegistryPath(command.RegistryKey);

            try
            {
                await new SetRegistryValueExecutor(directoryPath).Execute(command).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                await this.Console.WriteError($"Could not set registry value '{this.Verb.RegistryValueName}' to '{this.Verb.Value}' ({command.ValueType:G}) in '{target.Item1}\\{target.Item2}'.").ConfigureAwait(false);

                await this.Console.WriteError(e.Message).ConfigureAwait(false);

                return(StandardExitCodes.ErrorGeneric);
            }

            await this.Console.WriteSuccess($"Registry value '{this.Verb.RegistryValueName}' has been set to '{this.Verb.Value}' ({command.ValueType:G}) in '{target.Item1}\\{target.Item2}'.");

            return(StandardExitCodes.ErrorSuccess);
        }