Skip to content

Commit 9f07a58

Browse files
committed
Abstract type of the UpstreamHttpMethod property
1 parent 3632c69 commit 9f07a58

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/FileRouteBox.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@ public FileRouteBox<T> Priority(int priority)
4545
public FileRouteBox<T> Methods(params string[] methods)
4646
{
4747
//route.UpstreamHttpMethod = [.. methods];
48-
var property = Me.GetProperty("UpstreamHttpMethod");
49-
IList upstreamHttpMethod = property?.GetValue(Instance) as IList
50-
?? throw new ArgumentNullException(nameof(upstreamHttpMethod));
51-
foreach (var method in methods)
52-
{
53-
upstreamHttpMethod.Add(method);
54-
}
48+
var property = Me.GetProperty("UpstreamHttpMethod") ?? throw new NullReferenceException("UpstreamHttpMethod");
49+
var collection = Activator.CreateInstance(property.PropertyType, (IEnumerable<string>)methods);
50+
property.SetValue(Instance, collection);
5551
return this;
5652
}
5753

src/Ocelot.Testing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<IncludeSymbols>True</IncludeSymbols>
99
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1010
<!--Package properties-->
11-
<Version>24.0.3-beta.1</Version>
11+
<Version>24.0.3-beta.2</Version>
1212
<PackageId>Ocelot.Testing</PackageId>
1313
<PackageDescription>A shared library for testing the Ocelot core library and its extension packages, including both acceptance and unit tests</PackageDescription>
1414
<PackageReleaseNotes>https://github.com/ThreeMammals/Ocelot.Testing/releases</PackageReleaseNotes>

0 commit comments

Comments
 (0)