Skip to content

Commit f740027

Browse files
committed
update pkg version
1 parent 6681d27 commit f740027

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,60 @@
1-
using System.Collections.Generic;
1+
// Copyright (c) Code Impressions, LLC. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License")
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using System.Collections.Generic;
216
using System.Collections.Specialized;
317
using System.Linq;
418
using Transmitly.Delivery;
519

620
namespace Transmitly.Microsoft.Aspnet.Mvc
721
{
8-
/// <summary>
9-
/// Wraps the provided value provider and request body into the expected adaptor context.
10-
/// </summary>
11-
/// <param name="valueProvider">Querystring parameters.</param>
12-
/// <param name="requestBody">Request string body.</param>
13-
internal sealed class DefaultRequestAdaptorContext(NameValueCollection valueProvider, string requestBody) : IRequestAdaptorContext
14-
{
15-
private readonly NameValueCollection _valueProvider = valueProvider;
22+
/// <summary>
23+
/// Wraps the provided value provider and request body into the expected adaptor context.
24+
/// </summary>
25+
/// <param name="valueProvider">Querystring parameters.</param>
26+
/// <param name="requestBody">Request string body.</param>
27+
internal sealed class DefaultRequestAdaptorContext(NameValueCollection valueProvider, string requestBody) : IRequestAdaptorContext
28+
{
29+
private readonly NameValueCollection _valueProvider = valueProvider;
30+
private readonly Dictionary<string, string> _queryString = valueProvider.AllKeys.ToDictionary(k => k, k => valueProvider[k]);
31+
32+
public string GetValue(string key)
33+
{
34+
return _valueProvider.GetValues(key).FirstOrDefault();
35+
}
36+
37+
public string? GetQueryValue(string key)
38+
{
39+
return GetValue(key);
40+
}
41+
42+
public string? GetFormValue(string key)
43+
{
44+
return GetValue(key);
45+
}
1646

17-
public string GetValue(string key)
18-
{
19-
return _valueProvider.GetValues(key).FirstOrDefault();
20-
}
47+
public string? GetHeaderValue(string key)
48+
{
49+
return GetValue(key);
50+
}
2151

22-
public string Content { get; } = requestBody;
52+
public string Content { get; } = requestBody;
2353

24-
public string PipelineName => GetValue(DeliveryUtil.PipelineNameKey);
54+
public string PipelineName => GetValue(DeliveryUtil.PipelineNameKey);
2555

26-
public string ResourceId => GetValue(DeliveryUtil.ResourceIdKey);
56+
public string ResourceId => GetValue(DeliveryUtil.ResourceIdKey);
2757

28-
public IDictionary<string, string> QueryString => _valueProvider.AllKeys.ToDictionary(k => k, k => _valueProvider[k]);
29-
}
58+
public IDictionary<string, string> QueryString => _queryString;
59+
}
3060
}

0 commit comments

Comments
 (0)