예제 #1
0
            internal static ValueTask DoUnaryOperation(ref int value, UnaryOperationCommand command, CancellationToken token)
            {
                value = command.Type switch
                {
                    UnaryOperation.Negate => - command.X,
                    UnaryOperation.OnesComplement => ~command.X,
                    _ => throw new NotSupportedException()
                };

                return(new ValueTask());
            }
예제 #2
0
 unsafe long?IFormatter <UnaryOperationCommand> .GetLength(UnaryOperationCommand command)
 => sizeof(UnaryOperationCommand);
예제 #3
0
            async ValueTask IFormatter <UnaryOperationCommand> .SerializeAsync <TWriter>(UnaryOperationCommand command, TWriter writer, CancellationToken token)
            {
                await writer.WriteInt32Async(command.X, true, token);

                await writer.WriteAsync(command.Type, token);
            }
예제 #4
0
 public ValueTask DoUnaryOperation(UnaryOperationCommand command, CancellationToken token)
 => DoUnaryOperation(ref Value, command, token);