public IOperation ReadOperation(IDictionary <byte, object> parameters)
        {
            var operationId   = (byte)parameters[(byte)OperationParameterCode.OperationId];
            var operationData = (byte[])parameters[(byte)OperationParameterCode.OperationData];

            return((IOperation)_serializer.ReadObject(_map.GetMappedOperation(operationId).OperationType, operationData));
        }
 public void WriteOperation(IOperation operation)
 {
     _transport.SendOperation(OperationCode.HandleOperation, new Dictionary <byte, object>
     {
         [(byte)OperationParameterCode.OperationId]   = _map.GetMappedOperation(operation.GetType()).Id,
         [(byte)OperationParameterCode.OperationData] = _serializer.WriteObject(operation.GetType(), operation)
     });
 }
        public void ShouldRetrieveOperationByType()
        {
            var map = new OperationMap();

            var mappedOperation = map.MapOperation(typeof(TestOperation));

            map.GetMappedOperation(mappedOperation.OperationType).ShouldBe(mappedOperation);
        }
        public void ShouldWriteOperation()
        {
            var writer = new NetworkOperationWriter(_map, new SerializationService(new BinarySerializer()), _transport);

            writer.WriteOperation(new TestOperation());

            var sentOperation = _transport.SentOperations.SingleOrDefault();

            sentOperation.ShouldNotBeNull();

            sentOperation.Item1.ShouldBe(OperationCode.HandleOperation);

            sentOperation.Item2.ShouldContainKeyAndValue((byte)OperationParameterCode.OperationId, _map.GetMappedOperation(typeof(TestOperation)).Id);
            sentOperation.Item2.ShouldContainKey((byte)OperationParameterCode.OperationData);
        }