Skip to content
This repository was archived by the owner on Apr 2, 2023. It is now read-only.

Commit c5a3c0d

Browse files
committed
Update reference packages. Add new target framework .NET6.0
1 parent 698efc8 commit c5a3c0d

File tree

11 files changed

+523
-458
lines changed

11 files changed

+523
-458
lines changed

SDK.Test/SDK.Test.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
11-
<PackageReference Include="xunit" Version="2.3.1" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
11+
<PackageReference Include="xunit" Version="2.4.1" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
13+
<PrivateAssets>all</PrivateAssets>
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
</PackageReference>
1316
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
1417
</ItemGroup>
1518

SDK.Test/UnitTest1.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ namespace SDK.Test
66
{
77
public class UnitTest1
88
{
9+
910
[Fact]
1011
public void TestPushTokenOfiOS()
1112
{
1213
string result = null;
1314
Random random = new Random();
1415
int messageIndex = random.Next(9999);
15-
result = XingeApp.XingeApp.PushTokeniOs("5412567459229", 2200262432, "24f595178abda55aa74dc2ce4033d600", "CSharpSDK " + messageIndex,"1043b93f56334bf010d40ccefa1244d8557a45161d55ff3ecbb7e1b13e192f65", XingeApp.XingeApp.PushEnvironmentofiOs.Develop);
16+
result = XingeApp.XingeApp.PushTokeniOS("5412567459229", 2200262432, "24f595178abda55aa74dc2ce4033d600", "CSharpSDK " + messageIndex,"1043b93f56334bf010d40ccefa1244d8557a45161d55ff3ecbb7e1b13e192f65", XingeApp.XingeApp.PushEnvironmentofiOs.Develop);
1617
Console.WriteLine(result);
1718
}
1819
[Fact]
@@ -30,7 +31,7 @@ public void TestPushAccountOfiOS()
3031
string result = null;
3132
Random random = new Random();
3233
int messageIndex = random.Next(9999);
33-
result = XingeApp.XingeApp.PushAccountiOs("5412567459229", 2200262432, "24f595178abda55aa74dc2ce4033d600", "CSharpSDK " + messageIndex,"your test account", XingeApp.XingeApp.PushEnvironmentofiOs.Develop);
34+
result = XingeApp.XingeApp.PushAccountiOS("5412567459229", 2200262432, "24f595178abda55aa74dc2ce4033d600", "CSharpSDK " + messageIndex,"your test account", XingeApp.XingeApp.PushEnvironmentofiOs.Develop);
3435
Console.WriteLine(result);
3536
}
3637
[Fact]
@@ -48,7 +49,7 @@ public void TestPushTagOfiOS()
4849
string result = null;
4950
Random random = new Random();
5051
int messageIndex = random.Next(9999);
51-
result = XingeApp.XingeApp.PushTagiOs("5412567459229", 2200262432, "24f595178abda55aa74dc2ce4033d600", "CSharpSDK " + messageIndex,"your_test_tag", XingeApp.XingeApp.PushEnvironmentofiOs.Develop);
52+
result = XingeApp.XingeApp.PushTagiOS("5412567459229", 2200262432, "24f595178abda55aa74dc2ce4033d600", "CSharpSDK " + messageIndex,"your_test_tag", XingeApp.XingeApp.PushEnvironmentofiOs.Develop);
5253
Console.WriteLine(result);
5354
}
5455

@@ -68,7 +69,7 @@ public void TestPushAllOfiOS()
6869
string result = null;
6970
Random random = new Random();
7071
int messageIndex = random.Next(9999);
71-
result = XingeApp.XingeApp.PushAlliOs("5412567459229", 2200262432, "24f595178abda55aa74dc2ce4033d600", "CSharpSDK " + messageIndex, XingeApp.XingeApp.PushEnvironmentofiOs.Develop);
72+
result = XingeApp.XingeApp.PushAlliOS("5412567459229", 2200262432, "24f595178abda55aa74dc2ce4033d600", "CSharpSDK " + messageIndex, XingeApp.XingeApp.PushEnvironmentofiOs.Develop);
7273
Console.WriteLine(result);
7374
}
7475
[Fact]

SDK/ClickAction.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32

43

54
namespace XingeApp
@@ -16,22 +15,26 @@ public class ClickAction
1615
private string m_activity;
1716
private string m_intent;
1817

19-
public void setActionType(int actionType) { this.m_actionType = actionType; }
20-
public void setActivity(string activity) { this.m_activity = activity; }
21-
public void setUrl(string url) { this.m_url = url; }
22-
public void setConfirmUrl(int confirmUrl) { this.m_confirmUrl = confirmUrl; }
23-
public void setIntent(string intent) { this.m_intent = intent; }
18+
public void setActionType(int actionType) { m_actionType = actionType; }
19+
public void setActivity(string activity) { m_activity = activity; }
20+
public void setUrl(string url) { m_url = url; }
21+
public void setConfirmUrl(int confirmUrl) { m_confirmUrl = confirmUrl; }
22+
public void setIntent(string intent) { m_intent = intent; }
2423

2524
public Dictionary<string,object> toJson()
2625
{
27-
Dictionary<string,object> dict = new Dictionary<string, object>();
28-
dict.Add("action_type", m_actionType);
29-
dict.Add("activity", m_activity);
30-
dict.Add("intent", m_intent);
31-
Dictionary<string, object> browser = new Dictionary<string, object>();
32-
browser.Add("url", m_url);
33-
browser.Add("confirm", m_confirmUrl);
34-
dict.Add("browser", browser);
26+
var dict = new Dictionary<string, object>
27+
{
28+
{ "action_type", m_actionType },
29+
{ "activity", m_activity },
30+
{ "intent", m_intent }
31+
};
32+
var browser = new Dictionary<string, object>
33+
{
34+
{ "url", m_url },
35+
{ "confirm", m_confirmUrl }
36+
};
37+
dict.Add("browser", browser);
3538

3639
//string jsonData = JsonConvert.SerializeObject(dict);
3740
return dict;
@@ -44,15 +47,11 @@ public bool isValid()
4447
return false;
4548
if(m_actionType == TYPE_URL)
4649
{
47-
if (m_url.Length == 0 || m_confirmUrl < 0 || m_confirmUrl > 1)
48-
return false;
49-
return true;
50+
return m_url.Length != 0 && m_confirmUrl >= 0 && m_confirmUrl <= 1;
5051
}
5152
if(m_actionType == TYPE_INTENT)
5253
{
53-
if (m_intent.Length == 0)
54-
return false;
55-
return true;
54+
return m_intent.Length != 0;
5655
}
5756
return true;
5857
}

SDK/IXingeApp.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Threading.Tasks;
43

54
namespace XingeApp

SDK/Message.cs

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using Newtonsoft.Json;
1+
using System.Collections.Generic;
2+
using System.Linq;
43
using Newtonsoft.Json.Linq;
54

65
namespace XingeApp
@@ -24,88 +23,87 @@ public class Message
2423

2524
public Message()
2625
{
27-
this.m_title = "";
28-
this.m_content = "";
29-
this.m_sendTime = "";
30-
this.m_acceptTimes = new List<TimeInterval>();
31-
this.m_multiPkg = 0;
32-
this.m_raw = "";
33-
this.m_loopInterval = -1;
34-
this.m_loopTimes = -1;
35-
this.m_action = new ClickAction();
36-
this.m_style = new Style(0);
37-
this.m_pushID = 0;
26+
m_title = "";
27+
m_content = "";
28+
m_sendTime = "";
29+
m_acceptTimes = new List<TimeInterval>();
30+
m_multiPkg = 0;
31+
m_raw = "";
32+
m_loopInterval = -1;
33+
m_loopTimes = -1;
34+
m_action = new ClickAction();
35+
m_style = new Style(0);
36+
m_pushID = 0;
3837
}
3938

4039
public void setTitle(string title)
4140
{
42-
this.m_title = title;
41+
m_title = title;
4342
}
4443
public void setContent(string content)
4544
{
46-
this.m_content = content;
45+
m_content = content;
4746
}
4847
public void setExpireTime(int expireTime)
4948
{
50-
this.m_expireTime = expireTime;
49+
m_expireTime = expireTime;
5150
}
5251
public int getExpireTime()
5352
{
54-
return this.m_expireTime;
53+
return m_expireTime;
5554
}
5655
public void setSendTime(string sendTime)
5756
{
58-
this.m_sendTime = sendTime;
57+
m_sendTime = sendTime;
5958
}
6059
public string getSendTime()
6160
{
62-
return this.m_sendTime;
61+
return m_sendTime;
6362
}
6463
public void addAcceptTime(TimeInterval acceptTime)
6564
{
66-
this.m_acceptTimes.Add(acceptTime);
65+
m_acceptTimes.Add(acceptTime);
6766
}
6867
public JArray acceptTimeToJsonArray()
6968
{
70-
JArray json = new JArray();
71-
foreach (TimeInterval ti in m_acceptTimes)
69+
var json = new JArray();
70+
foreach (var jtemp in m_acceptTimes.Select(ti => JObject.FromObject(ti.toJson())))
7271
{
73-
JObject jtemp = JObject.FromObject(ti.toJson());
7472
json.Add(jtemp);
7573
}
7674
return json;
7775
}
7876
public void setType(string type)
7977
{
80-
this.m_type = type;
78+
m_type = type;
8179
}
8280
public string getType()
8381
{
8482
return m_type;
8583
}
8684
public void setMultiPkg(int multiPkg)
8785
{
88-
this.m_multiPkg = multiPkg;
86+
m_multiPkg = multiPkg;
8987
}
9088
public int getMultiPkg()
9189
{
9290
return m_multiPkg;
9391
}
9492
public void setStyle(Style style)
9593
{
96-
this.m_style = style;
94+
m_style = style;
9795
}
9896
public void setAction(ClickAction action)
9997
{
100-
this.m_action = action;
98+
m_action = action;
10199
}
102100
public void setCustom(Dictionary<string, object> custom)
103101
{
104-
this.m_custom = custom;
102+
m_custom = custom;
105103
}
106104
public void setRaw(string raw)
107105
{
108-
this.m_raw = raw;
106+
m_raw = raw;
109107
}
110108
public int getLoopInterval()
111109
{
@@ -148,23 +146,19 @@ public bool isValid()
148146
}
149147
if (m_expireTime < 0 || m_expireTime > 3 * 24 * 60 * 60)
150148
return false;
151-
foreach(TimeInterval ti in m_acceptTimes)
152-
{
153-
if (!ti.isValid()) return false;
154-
}
155-
if(m_loopInterval > 0 && m_loopTimes > 0 && ((m_loopTimes - 1) * m_loopInterval + 1) > 15)
149+
if (m_acceptTimes.Any(ti => !ti.isValid()))
156150
{
157151
return false;
158152
}
159-
return true;
153+
return m_loopInterval <= 0 || m_loopTimes <= 0 || ((m_loopTimes - 1) * m_loopInterval + 1) <= 15;
160154
}
161155

162156
public object toJson()
163157
{
164158
if (m_raw.Length != 0)
165159
return m_raw;
166-
Dictionary<string, object> dict = new Dictionary<string, object>();
167-
Dictionary<string, object> message = new Dictionary<string, object>();
160+
var dict = new Dictionary<string, object>();
161+
var message = new Dictionary<string, object>();
168162

169163
dict.Add("title", m_title);
170164
dict.Add("content", m_content);
@@ -191,7 +185,7 @@ public object toJson()
191185
//
192186
}
193187

194-
if (this.m_custom != null)
188+
if (m_custom != null)
195189
{
196190
foreach(var kvp in m_custom)
197191
{

0 commit comments

Comments
 (0)