예제 #1
0
        public async Task WriteValueAsync(RegistryBaseKey baseKey, string key, string valueName, string value)
        {
            var command = new RegistryWriteStringValueCommand(baseKey, key, valueName, value);
            IServiceCommandResponse response = await _commandBridge.SendCommandAsync(command);

            response.ThrowIfError();
        }
예제 #2
0
        private static bool TryDeserialize(
            BridgeMessageDeserializer deserializer,
            out IServiceCommand command,
            out IServiceCommandResponse errorResponse)
        {
            switch (deserializer.CommandName)
            {
            case ServiceCommandName.ShutdownServer:
                command = new ShutdownServerCommand();
                break;

            case ServiceCommandName.Echo:
                command = new EchoCommand(deserializer);
                break;

            case ServiceCommandName.RegistryReadIntValue:
                command = new RegistryReadIntValueCommand(deserializer);
                break;

            case ServiceCommandName.RegistryReadStringValue:
                command = new RegistryReadStringValueCommand(deserializer);
                break;

            case ServiceCommandName.RegistryWriteIntValue:
                command = new RegistryWriteIntValueCommand(deserializer);
                break;

            case ServiceCommandName.RegistryWriteStringValue:
                command = new RegistryWriteStringValueCommand(deserializer);
                break;

            case ServiceCommandName.Unknown:
            default:
                throw new InvalidOperationException(
                          "This should be unreachable because the deserializer should have detected an invalid command name");
            }

            if (deserializer.HadError)
            {
                command = null;
            }
            errorResponse = deserializer.LastError;
            return(!deserializer.HadError);
        }