public string GetMethodName(Type type) { if (MethodNames.TryGetValue(type, out var method)) { return(method); } // Custom method var attribute = MethodAttribute.From(type); var handler = KnownHandlers.SelectMany(z => z) .FirstOrDefault(z => z.InterfaceType == type || z.HandlerType == type || z.ParamsType == type); if (handler != null) { return(handler.Method); } // TODO: Log unknown method name if (attribute is null) { return(null); } MethodNames.TryAdd(type, attribute.Method); return(attribute.Method); }
public void HandlersShouldMatchParamsMethodAttribute(Type type) { var paramsType = HandlerTypeDescriptorHelper.GetHandlerInterface(type).GetGenericArguments()[0]; var lhs = MethodAttribute.From(type) !; var rhs = MethodAttribute.From(paramsType) !; lhs.Method.Should().Be(rhs.Method, $"{type.FullName} method does not match {paramsType.FullName}"); lhs.Direction.Should().Be(rhs.Direction, $"{type.FullName} direction does not match {paramsType.FullName}"); }