예제 #1
0
        public static Type GetPayloadType(this IBigMessage bigMessage)
        {
            var messageType = bigMessage.Type;

            if (messageType.IsInterface)
            {
                var inheritors = (from assemblyType in EventTypes.Value
                                  where messageType.IsAssignableFrom(assemblyType) && messageType != assemblyType
                                  select assemblyType).ToList();
                if (inheritors.Count != 1)
                {
                    throw new InvalidOperationException($"Incorrect inheritors number {inheritors.Count}");
                }

                messageType = inheritors[0];
            }

            return(messageType);
        }
예제 #2
0
 /// <inheritdoc />
 public async Task <object> GetMessageAsync(IBigMessage bigMessage) =>
 _serializer.Deserialize(
     await _storage.GetAsync(bigMessage.Address).ConfigureAwait(false),
     bigMessage.GetPayloadType());