Skip to content

Commit e794386

Browse files
committed
GSF.TimeSeries: Prevent AmbiguousMatchException in Invoke command if only one of the matching methods has the AdapterCommandAttribute
1 parent 0fe9903 commit e794386

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Source/Libraries/GSF.TimeSeries/ServiceHostBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,13 @@ protected virtual void InvokeRequestHandler(ClientRequestInfo requestInfo)
20892089
try
20902090
{
20912091
// See if method exists with specified name using reflection
2092-
MethodInfo method = adapter.GetType().GetMethod(command, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase);
2092+
MethodInfo method = adapter
2093+
.GetType()
2094+
.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase)
2095+
.Where(method => method.Name == command)
2096+
.Where(method => method.TryGetAttribute(out AdapterCommandAttribute _))
2097+
.Select((method, index) => index == 0 ? method : throw new AmbiguousMatchException())
2098+
.LastOrDefault();
20932099

20942100
// Invoke method
20952101
if (method is not null)

0 commit comments

Comments
 (0)