コード例 #1
0
 private void Validate()
 {
     if (!typeof(IDelegatingHandler).GetTypeInfo().IsAssignableFrom(HandlerType.GetTypeInfo()))
     {
         throw new TypeIsNotDelegatingHandlerException(HandlerType);
     }
 }
コード例 #2
0
        private void Validate()
        {
            var handlerType = HandlerType.GetTypeInfo();

            if (!typeof(IDelegatingHandler).GetTypeInfo().IsAssignableFrom(handlerType) &&
                !typeof(ICancelableDelegatingHandler).GetTypeInfo().IsAssignableFrom(handlerType))
            {
                throw new TypeIsNotDelegatingHandlerException(HandlerType);
            }
        }
コード例 #3
0
        private void Validate()
        {
            var handlerMessageTypes = HandlerType.GetTypeInfo()
                                      .ImplementedInterfaces
                                      .Where(x => x.GetTypeInfo().IsGenericType&& x.GetGenericTypeDefinition() == typeof(IMessageHandler <,>))
                                      .Select(x => x.GenericTypeArguments.First())
                                      .ToArray();

            if (handlerMessageTypes.Any() && handlerMessageTypes.All(x => !x.GetTypeInfo().IsAssignableFrom(MessageType.GetTypeInfo())))
            {
                throw new ArgumentException(string.Format("The handler {0} cannot handle message of type {1}", HandlerType.Name, MessageType.Name));
            }
        }