Skip to content

Commit 3d9a175

Browse files
committed
Added support for actions ending with "Async".
1 parent 3bbcd39 commit 3d9a175

File tree

6 files changed

+34
-19
lines changed

6 files changed

+34
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ var webService = new WebService("https://www.myserver.com/", HttpMethod.Get);
1616
Getting the response for an action *TestAction*:
1717
```C#
1818
var request = new Request<JObject>(webService);
19-
JObject response = request.Call();
19+
JObject response = request.Call("TestAction");
2020
```
2121

2222
The above example was synchronous and blocked the calling thread.
2323

2424
The asynchronous call looks like this:
2525
```C#
26-
JObject response = await request.CallAsyncTask(nameof(TestActionAsyncTask));
26+
JObject response = await request.CallAsync(nameof(TestActionAsync));
2727
```
2828

2929
To send parameters to the server, add them to the ```Parameter``` property of the request before calling:

src/BlueWSClient.NET/BlueWSClient.NET.Test/BlueWSClient.NET.Test.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
3535
<ItemGroup>
36-
<Reference Include="GM.Utility, Version=1.2.1.0, Culture=neutral, PublicKeyToken=a1ae152199607549, processorArchitecture=MSIL">
37-
<HintPath>..\packages\GM.Utility.1.2.1\lib\netstandard2.0\GM.Utility.dll</HintPath>
36+
<Reference Include="GM.Utility, Version=1.2.4.0, Culture=neutral, PublicKeyToken=a1ae152199607549, processorArchitecture=MSIL">
37+
<HintPath>..\packages\GM.Utility.1.2.4\lib\netstandard2.0\GM.Utility.dll</HintPath>
3838
</Reference>
39-
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
40-
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
39+
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
4141
</Reference>
4242
<Reference Include="System" />
4343
<Reference Include="System.Core" />

src/BlueWSClient.NET/BlueWSClient.NET.Test/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[assembly: AssemblyTitle("BlueWSClient.NET.Test")]
99
[assembly: AssemblyDescription("")]
1010
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyCompany("Grega Mohorko")]
1212
[assembly: AssemblyProduct("BlueWSClient.NET.Test")]
1313
[assembly: AssemblyCopyright("Copyright © Grega Mohorko 2017")]
1414
[assembly: AssemblyTrademark("")]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="GM.Utility" version="1.2.1" targetFramework="net461" />
4-
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
3+
<package id="GM.Utility" version="1.2.4" targetFramework="net461" />
4+
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" />
55
</packages>

src/BlueWSClient.NET/BlueWSClient.NET/BlueWSClient.NET.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<AssemblyName>BlueWS</AssemblyName>
66
<RootNamespace>BlueWS</RootNamespace>
7-
<Version>1.2.1.0</Version>
7+
<Version>1.2.2.0</Version>
88
<Title>BlueWS</Title>
99
<Authors>Grega Mohorko</Authors>
1010
<Company>Grega Mohorko</Company>
@@ -14,9 +14,9 @@
1414
<PackageProjectUrl>https://github.com/GregaMohorko/BlueWSClient.NET</PackageProjectUrl>
1515
<PackageIconUrl>https://raw.githubusercontent.com/GregaMohorko/BlueWS/master/Documentation/Icon/BlueWS.ico</PackageIconUrl>
1616
<PackageTags>EntityFramework Entity Database JSON Criteria Expression TableInheritance ManyToOne OneToMany ManyToMany MySQL</PackageTags>
17-
<PackageReleaseNotes>Used web client from GM.Utility.</PackageReleaseNotes>
18-
<AssemblyVersion>1.2.1.0</AssemblyVersion>
19-
<FileVersion>1.2.1.0</FileVersion>
17+
<PackageReleaseNotes>Added support for actions ending with "Async" phrase (was just "AsyncTask" before).</PackageReleaseNotes>
18+
<AssemblyVersion>1.2.2.0</AssemblyVersion>
19+
<FileVersion>1.2.2.0</FileVersion>
2020
<SignAssembly>true</SignAssembly>
2121
<DelaySign>false</DelaySign>
2222
<AssemblyOriginatorKeyFile>GM.StrongNameKey.snk</AssemblyOriginatorKeyFile>
@@ -29,11 +29,12 @@
2929

3030
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
3131
<DocumentationFile>bin\Debug\netstandard2.0\BlueWS.xml</DocumentationFile>
32+
<NoWarn />
3233
</PropertyGroup>
3334

3435
<ItemGroup>
35-
<PackageReference Include="GM.Utility" Version="1.2.1" />
36-
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
36+
<PackageReference Include="GM.Utility" Version="1.2.4" />
37+
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
3738
</ItemGroup>
3839

3940
</Project>

src/BlueWSClient.NET/BlueWSClient.NET/Request.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,29 @@ public T Call(string action = null)
113113
/// <para> If the action ends with the phrase "AsyncTask", that phrase will be cut out. So you can use <c>nameof</c>.</para>
114114
/// </summary>
115115
/// <param name="action">The name of the action to call. If it ends with the phrase "AsyncTask", that phrase will be cut out. So you can use <c>nameof</c>.</param>
116-
[MethodImpl(MethodImplOptions.NoInlining)]
117-
public async Task<T> CallAsyncTask(string action)
116+
[Obsolete("This method is obsolete. Please use CallAsync instead.",false)]
117+
public Task<T> CallAsyncTask(string action)
118+
{
119+
// FIXME obsolete 2018-03-21
120+
return CallAsync(action);
121+
}
122+
123+
/// <summary>
124+
/// Calls the associated server with the specified action as an asynchronous action.
125+
/// <para> If the action ends with the phrase "Async" or "AsyncTask", that phrase will be cut out. So you can use <c>nameof</c>.</para>
126+
/// </summary>
127+
/// <param name="action">The name of the action to call. If it ends with the phrase "Async" or "AsyncTask", that phrase will be cut out. So you can use <c>nameof</c>.</param>
128+
public async Task<T> CallAsync(string action)
118129
{
119130
if(action.EndsWith("AsyncTask")) {
120131
// "AsyncTask".Length == 9
121132
action = action.Substring(0, action.Length - 9);
133+
} else if(action.EndsWith("Async")) {
134+
// "Async".Length == 5
135+
action = action.Substring(0, action.Length - 5);
122136
}
123137

124-
NameValueCollection data=BeforeCalling(action);
138+
NameValueCollection data = BeforeCalling(action);
125139

126140
try {
127141
string address = WebService.ServerAddress;
@@ -133,7 +147,7 @@ public async Task<T> CallAsyncTask(string action)
133147
} catch(WebException e) {
134148
OnWebException(e);
135149
}
136-
150+
137151
return Response;
138152
}
139153

0 commit comments

Comments
 (0)