Пример #1
0
        private ((Type responseType, Type requestType) key, ExecutionContext ctx) HandleMethodSelector(
            IOutputPortHandler handler)
        {
            var type = handler.GetType();

            var methodInfo = type.GetMethod(GET_FUNCTION_NAME);

            var @interface = type.GetInterfaces()
                             .FirstOrDefault(x => x.IsGenericType && typeof(IOutputPortHandler <,>) == x.GetGenericTypeDefinition());

            if (methodInfo == null || @interface == null)
            {
                throw new ArchitectureVolationException(
                          $"Every {nameof(IOutputPortHandler)} should implement generic interface with \"Get\" method");
            }

            var responseType = @interface?.GetGenericArguments().FirstOrDefault();

            var requestType = @interface?.GetGenericArguments().LastOrDefault();

            return((responseType, requestType), new ExecutionContext(methodInfo, handler));
        }
Пример #2
0
 public ExecutionContext(MethodInfo method, IOutputPortHandler executionObject)
 {
     _method          = method;
     _executionObject = executionObject;
 }