-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathModule.cs
55 lines (49 loc) · 2.48 KB
/
Module.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
namespace Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph
{
/// <summary>A class that contains the module-common code and data.</summary>
public partial class Module
{
partial void AfterCreatePipeline(global::System.Management.Automation.InvocationInfo invocationInfo, ref Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.HttpPipeline pipeline)
{
pipeline.Append(SendAsync);
}
public async System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.IEventListener callback, Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.ISendAsync next)
{
string search = "Search=";
string splitter = "&";
string query = request.RequestUri.Query;
int start = query.IndexOf(search, System.StringComparison.OrdinalIgnoreCase);
int end = 0;
if (start >= 0 && query.Length > start + search.Length -1)
{
start += search.Length;
end = query.IndexOf(splitter, start, System.StringComparison.OrdinalIgnoreCase);
if (start == end)
{
return await next.SendAsync(request, callback);
}
if (end == -1)
{
end = query.Length;
}
search = query.Substring(start, end - start);
//Remove " in search query
search = System.Text.RegularExpressions.Regex.Replace(search, "^%22|%22$", "");
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(query.Substring(0, start));
sb.Append("\"");
sb.Append(search);
sb.Append("\"");
sb.Append(query.Substring(end));
System.UriBuilder ub = new System.UriBuilder(request.RequestUri);
ub.Query = sb.ToString();
request.RequestUri = ub.Uri;
}
return await next.SendAsync(request, callback);
}
}
}