Skip to content

Commit 7d20273

Browse files
committed
Addressing comments
1 parent 29a9509 commit 7d20273

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/Mvc/Mvc.Abstractions/src/ModelBinding/BindingInfo.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,16 @@ public Type? BinderType
178178
}
179179

180180
// Keyed services
181-
if (attributes.Any(a => typeof(IFromServiceMetadata).IsAssignableFrom(a.GetType())))
181+
if (attributes.OfType<FromKeyedServicesAttribute>().FirstOrDefault() is { } fromKeyedServicesAttribute)
182182
{
183-
if (attributes.OfType<FromKeyedServicesAttribute>().FirstOrDefault() is not null)
183+
if (bindingInfo.BindingSource != null)
184184
{
185185
throw new NotSupportedException(
186-
$"The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IFromServiceMetadata)}.");
186+
$"The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IBindingSourceMetadata)}.");
187187
}
188-
}
189-
if (attributes.OfType<FromKeyedServicesAttribute>().FirstOrDefault() is { } fromKeydServicesAttribute)
190-
{
191188
isBindingInfoPresent = true;
192189
bindingInfo.BindingSource = BindingSource.Services;
193-
bindingInfo.ServiceKey = fromKeydServicesAttribute.Key;
190+
bindingInfo.ServiceKey = fromKeyedServicesAttribute.Key;
194191
}
195192

196193
return isBindingInfoPresent ? bindingInfo : null;

0 commit comments

Comments
 (0)