Skip to content

Commit 84b5df3

Browse files
author
喵喵大人
authored
Merge pull request #23 from CatLib/feature/1.2.6
Feature/1.2.6
2 parents 82fdb57 + 873c98c commit 84b5df3

30 files changed

+1998
-216
lines changed

CatLib.Core.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27004.2002
4+
VisualStudioVersion = 15.0.27130.2036
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CatLib.Core", "src\CatLib.Core\CatLib.Core.csproj", "{4204658E-81FD-4106-A347-890CD369C8A4}"
77
EndProject

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
**使用Nuget安装**
2929

3030
```PM
31-
Install-Package CatLib.Core -Version 1.2.5
31+
Install-Package CatLib.Core -Version 1.2.6
3232
```
3333

3434
**直接下载发布版本**

src/CatLib.Core.NetStandard/CatLib.Core.NetStandard.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</PropertyGroup>
4646

4747
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
48-
<DefineConstants>TRACE;DEBUG;NETSTANDARD2_0;CATLIB;</DefineConstants>
48+
<DefineConstants>TRACE;DEBUG;NETSTANDARD2_0;CATLIB;CATLIB_PERFORMANCE;NETSTANDARD2_0</DefineConstants>
4949
<DocumentationFile></DocumentationFile>
5050
</PropertyGroup>
5151

@@ -58,11 +58,16 @@
5858
<Compile Include="..\CatLib.Core\CatLib\Application.cs" Link="CatLib\Application.cs" />
5959
<Compile Include="..\CatLib.Core\CatLib\ApplicationEvents.cs" Link="CatLib\ApplicationEvents.cs" />
6060
<Compile Include="..\CatLib.Core\CatLib\DebugLevels.cs" Link="CatLib\DebugLevels.cs" />
61+
<Compile Include="..\CatLib.Core\CatLib\Events\DispatcherExtend.cs" Link="CatLib\Events\DispatcherExtend.cs" />
62+
<Compile Include="..\CatLib.Core\CatLib\Events\GlobalDispatcher.cs" Link="CatLib\Events\GlobalDispatcher.cs" />
63+
<Compile Include="..\CatLib.Core\CatLib\Events\IGlobalDispatcher.cs" Link="CatLib\Events\IGlobalDispatcher.cs" />
64+
<Compile Include="..\CatLib.Core\CatLib\Events\IOriginalDispatcher.cs" Link="CatLib\Events\IOriginalDispatcher.cs" />
6165
<Compile Include="..\CatLib.Core\CatLib\Facade.cs" Link="CatLib\Facade.cs" />
6266
<Compile Include="..\CatLib.Core\CatLib\IApplication.cs" Link="CatLib\IApplication.cs" />
6367
<Compile Include="..\CatLib.Core\CatLib\IBootstrap.cs" Link="CatLib\IBootstrap.cs" />
6468
<Compile Include="..\CatLib.Core\CatLib\IServiceProvider.cs" Link="CatLib\IServiceProvider.cs" />
6569
<Compile Include="..\CatLib.Core\CatLib\IServiceProviderType.cs" Link="CatLib\IServiceProviderType.cs" />
70+
<Compile Include="..\CatLib.Core\CatLib\ServiceProvider.cs" Link="CatLib\ServiceProvider.cs" />
6671
<Compile Include="..\CatLib.Core\Support\Attribute\ExcludeFromCodeCoverageAttribute.cs" Link="Support\Attribute\ExcludeFromCodeCoverageAttribute.cs" />
6772
<Compile Include="..\CatLib.Core\Support\Attribute\PriorityAttribute.cs" Link="Support\Attribute\PriorityAttribute.cs" />
6873
<Compile Include="..\CatLib.Core\Support\Container\Bindable.cs" Link="Support\Container\Bindable.cs" />
@@ -84,7 +89,6 @@
8489
<Compile Include="..\CatLib.Core\Support\Container\Params.cs" Link="Support\Container\Params.cs" />
8590
<Compile Include="..\CatLib.Core\Support\Container\UnresolvableException.cs" Link="Support\Container\UnresolvableException.cs" />
8691
<Compile Include="..\CatLib.Core\Support\Events\Dispatcher.cs" Link="Support\Events\Dispatcher.cs" />
87-
<Compile Include="..\CatLib.Core\Support\Events\DispatcherExtend.cs" Link="Support\Events\DispatcherExtend.cs" />
8892
<Compile Include="..\CatLib.Core\Support\Events\Event.cs" Link="Support\Events\Event.cs" />
8993
<Compile Include="..\CatLib.Core\Support\Events\IDispatcher.cs" Link="Support\Events\IDispatcher.cs" />
9094
<Compile Include="..\CatLib.Core\Support\Events\IEvent.cs" Link="Support\Events\IEvent.cs" />
@@ -96,6 +100,7 @@
96100
<Compile Include="..\CatLib.Core\Support\QuickList\InternalList.cs" Link="Support\QuickList\InternalList.cs" />
97101
<Compile Include="..\CatLib.Core\Support\QuickList\IQuickList.cs" Link="Support\QuickList\IQuickList.cs" />
98102
<Compile Include="..\CatLib.Core\Support\QuickList\QuickList.cs" Link="Support\QuickList\QuickList.cs" />
103+
<Compile Include="..\CatLib.Core\Support\RingBuffer\RingBuffer.cs" Link="Support\RingBuffer\RingBuffer.cs" />
99104
<Compile Include="..\CatLib.Core\Support\SortSet\ISortSet.cs" Link="Support\SortSet\ISortSet.cs" />
100105
<Compile Include="..\CatLib.Core\Support\SortSet\SortSet.cs" Link="Support\SortSet\SortSet.cs" />
101106
<Compile Include="..\CatLib.Core\Support\Template\IManaged.cs" Link="Support\Template\IManaged.cs" />
@@ -120,7 +125,7 @@
120125

121126
<ItemGroup>
122127
<Folder Include="..\CatLib.Core\Properties\" />
123-
<Folder Include="CatLib\" />
128+
<Folder Include="CatLib\Events\" />
124129
<Folder Include="Support\Attribute\" />
125130
<Folder Include="Support\Events\" />
126131
<Folder Include="Support\Exception\" />
@@ -129,6 +134,7 @@
129134
<Folder Include="Support\QuickList\" />
130135
<Folder Include="Support\SortSet\" />
131136
<Folder Include="Support\Template\" />
137+
<Folder Include="Support\RingBuffer\" />
132138
</ItemGroup>
133139

134140
</Project>

src/CatLib.Core.Tests/CatLib.Core.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<ItemGroup>
3737
<Compile Include="CatLib\ApplicationTests.cs" />
3838
<Compile Include="CatLib\FacaedTests.cs" />
39+
<Compile Include="CatLib\GlobalDispatcherTests.cs" />
3940
<Compile Include="Support\Container\ContainerPerformanceTests.cs" />
4041
<Compile Include="Support\Container\MethodContainerTests.cs" />
4142
<Compile Include="Support\Dispatcher\DispatcherTests.cs" />
@@ -48,6 +49,7 @@
4849
<Compile Include="Support\FilterChain\FilterChainTests.cs" />
4950
<Compile Include="Support\QuickList\InternalListTests.cs" />
5051
<Compile Include="Support\QuickList\QuickListTests.cs" />
52+
<Compile Include="Support\RingBuffer\RingBufferTests.cs" />
5153
<Compile Include="Support\SortSet\SortSetTests.cs" />
5254
<Compile Include="Support\Template\ManagerTests.cs" />
5355
<Compile Include="Support\Template\SingleManagerTests.cs" />
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
/*
2+
* This file is part of the CatLib package.
3+
*
4+
* (c) Yu Bin <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Document: http://catlib.io/
10+
*/
11+
12+
using Microsoft.VisualStudio.TestTools.UnitTesting;
13+
14+
namespace CatLib.Tests
15+
{
16+
[TestClass]
17+
public class GlobalDispatcherTests
18+
{
19+
[TestMethod]
20+
public void TestOn()
21+
{
22+
Application.New();
23+
24+
var n = string.Empty;
25+
var a = new object[]{};
26+
var r = new object();
27+
App.Listen("Events.On", (name, args) =>
28+
{
29+
n = name;
30+
a = args;
31+
return r;
32+
});
33+
34+
Assert.AreEqual(r, App.TriggerHalt("Events.On","helloworld", "catlib"));
35+
Assert.AreEqual("Events.On", n);
36+
Assert.AreEqual("helloworld", a[0]);
37+
Assert.AreEqual("catlib", a[1]);
38+
}
39+
40+
[TestMethod]
41+
public void TestDispatcherGroup()
42+
{
43+
Application.New();
44+
var isCall = false;
45+
App.On("Events", () =>
46+
{
47+
isCall = true;
48+
}, "catlib");
49+
50+
App.On("Events2", () =>
51+
{
52+
isCall = true;
53+
}, "catlib");
54+
55+
App.Trigger("Events");
56+
Assert.AreEqual(true, isCall);
57+
isCall = false;
58+
App.Trigger("Events2");
59+
Assert.AreEqual(true, isCall);
60+
isCall = false;
61+
62+
App.Off("catlib");
63+
App.Trigger("Events");
64+
App.Trigger("Events2");
65+
Assert.AreEqual(false, isCall);
66+
}
67+
68+
[TestMethod]
69+
public void TestT1()
70+
{
71+
var dispatcher = new Dispatcher();
72+
Application.New();
73+
var n = 0;
74+
dispatcher.On("Events.T1", (int num) =>
75+
{
76+
n = num;
77+
});
78+
79+
App.On("Events.T1",(int num) =>
80+
{
81+
n = num + 1;
82+
});
83+
84+
dispatcher.Listen("Events.T1.Listen", (int num) =>
85+
{
86+
n = num;
87+
return 100;
88+
});
89+
90+
App.Listen("Events.T1.Listen", (int num) =>
91+
{
92+
n = num + 1;
93+
return 200;
94+
});
95+
96+
var isCall = false;
97+
dispatcher.On("Events.T0", () =>
98+
{
99+
isCall = true;
100+
});
101+
102+
dispatcher.Listen("Events.T0.Listen", () =>
103+
{
104+
return 300;
105+
});
106+
107+
App.Listen("Events.T0.Listen", () =>
108+
{
109+
return 300;
110+
});
111+
112+
dispatcher.Trigger("Events.T1",199478);
113+
Assert.AreEqual(199478, n);
114+
App.Trigger("Events.T1", 199478);
115+
Assert.AreEqual(199479, n);
116+
117+
Assert.AreEqual(100, dispatcher.TriggerHalt("Events.T1.Listen", "abc", App.Handler, 199478));
118+
Assert.AreEqual(199478, n);
119+
Assert.AreEqual(200, App.TriggerHalt("Events.T1.Listen", "abcd", dispatcher, 199478));
120+
Assert.AreEqual(199479, n);
121+
122+
dispatcher.TriggerHalt("Events.T0", "abcd", dispatcher, 199478);
123+
Assert.AreEqual(true, isCall);
124+
Assert.AreEqual(300, dispatcher.TriggerHalt("Events.T0.Listen", "abcd", dispatcher, 199478));
125+
Assert.AreEqual(300, App.TriggerHalt("Events.T0.Listen", "abcd", dispatcher, 199478));
126+
}
127+
128+
[TestMethod]
129+
public void TestT1_2()
130+
{
131+
var dispatcher = new Dispatcher();
132+
Application.New();
133+
var n = 0;
134+
var s = string.Empty;
135+
dispatcher.On("Events.T1_2", (int num, string hello) =>
136+
{
137+
n = num;
138+
s = hello;
139+
});
140+
141+
App.On("Events.T1_2", (int num, string hello) =>
142+
{
143+
n = num + 1;
144+
s = hello;
145+
});
146+
147+
dispatcher.Listen("Events.T1_2.Listen", (int num, string hello) =>
148+
{
149+
n = num;
150+
s = hello;
151+
return 100;
152+
});
153+
154+
App.Listen("Events.T1_2.Listen", (int num, string hello) =>
155+
{
156+
n = num + 1;
157+
s = hello;
158+
return 200;
159+
});
160+
161+
dispatcher.Trigger("Events.T1_2", "abc",199478);
162+
Assert.AreEqual(199478, n);
163+
Assert.AreEqual("abc", s);
164+
App.Trigger("Events.T1_2", "abcd", 199478);
165+
Assert.AreEqual(199479, n);
166+
Assert.AreEqual("abcd", s);
167+
168+
Assert.AreEqual(100, dispatcher.TriggerHalt("Events.T1_2.Listen", "abc", App.Handler, 199478));
169+
Assert.AreEqual(199478, n);
170+
Assert.AreEqual("abc", s);
171+
Assert.AreEqual(200, App.TriggerHalt("Events.T1_2.Listen", "abcd", dispatcher, 199478));
172+
Assert.AreEqual(199479, n);
173+
Assert.AreEqual("abcd", s);
174+
}
175+
176+
[TestMethod]
177+
public void Test1_3()
178+
{
179+
var dispatcher = new Dispatcher();
180+
Application.New();
181+
var n = 0;
182+
var s = string.Empty;
183+
dispatcher.On("Events.T1_3", (int num, string hello, IDispatcher disp) =>
184+
{
185+
n = num;
186+
s = hello;
187+
Assert.AreEqual(App.Handler, disp);
188+
});
189+
190+
App.On("Events.T1_3", (int num, string hello, IDispatcher disp) =>
191+
{
192+
n = num + 1;
193+
s = hello;
194+
Assert.AreEqual(dispatcher, disp);
195+
});
196+
197+
dispatcher.Listen("Events.T1_3.Listen", (int num, string hello, IDispatcher disp) =>
198+
{
199+
n = num;
200+
s = hello;
201+
Assert.AreEqual(App.Handler, disp);
202+
return 100;
203+
});
204+
205+
App.Listen("Events.T1_3.Listen", (int num, string hello, IDispatcher disp) =>
206+
{
207+
n = num + 1;
208+
s = hello;
209+
Assert.AreEqual(dispatcher, disp);
210+
return 200;
211+
});
212+
213+
dispatcher.Trigger("Events.T1_3", "abc", App.Handler, 199478);
214+
Assert.AreEqual(199478, n);
215+
Assert.AreEqual("abc", s);
216+
App.Trigger("Events.T1_3", "abcd", dispatcher, 199478);
217+
Assert.AreEqual(199479, n);
218+
Assert.AreEqual("abcd", s);
219+
220+
Assert.AreEqual(100, dispatcher.TriggerHalt("Events.T1_3.Listen", "abc", App.Handler, 199478));
221+
Assert.AreEqual(199478, n);
222+
Assert.AreEqual("abc", s);
223+
Assert.AreEqual(200, App.TriggerHalt("Events.T1_3.Listen", "abcd", dispatcher, 199478));
224+
Assert.AreEqual(199479, n);
225+
Assert.AreEqual("abcd", s);
226+
}
227+
228+
[TestMethod]
229+
public void Test1_4()
230+
{
231+
var dispatcher = new Dispatcher();
232+
Application.New();
233+
var n = 0;
234+
var s = string.Empty;
235+
dispatcher.On("Events.T1_4", (int num, string hello, IDispatcher disp, IApplication application) =>
236+
{
237+
n = num;
238+
s = hello;
239+
Assert.AreEqual(App.Handler, disp);
240+
Assert.AreEqual(App.Handler, application);
241+
});
242+
243+
App.On("Events.T1_4", (int num, string hello, IDispatcher disp, IApplication application) =>
244+
{
245+
n = num + 1;
246+
s = hello;
247+
Assert.AreEqual(dispatcher, disp);
248+
Assert.AreEqual(App.Handler, application);
249+
});
250+
251+
dispatcher.Listen("Events.T1_4.Listen", (int num, string hello, IDispatcher disp, IApplication application) =>
252+
{
253+
n = num;
254+
s = hello;
255+
Assert.AreEqual(App.Handler, disp);
256+
Assert.AreEqual(App.Handler, application);
257+
return 100;
258+
});
259+
260+
App.Listen("Events.T1_4.Listen", (int num, string hello, IDispatcher disp, IApplication application) =>
261+
{
262+
n = num + 1;
263+
s = hello;
264+
Assert.AreEqual(dispatcher, disp);
265+
Assert.AreEqual(App.Handler, application);
266+
return 200;
267+
});
268+
269+
dispatcher.Trigger("Events.T1_4", "abc", App.Handler, 199478);
270+
Assert.AreEqual(199478, n);
271+
Assert.AreEqual("abc", s);
272+
App.Trigger("Events.T1_4", "abcd", dispatcher, 199478);
273+
Assert.AreEqual(199479, n);
274+
Assert.AreEqual("abcd", s);
275+
276+
Assert.AreEqual(100, dispatcher.TriggerHalt("Events.T1_4.Listen", "abc", App.Handler, 199478));
277+
Assert.AreEqual(199478, n);
278+
Assert.AreEqual("abc", s);
279+
Assert.AreEqual(200, App.TriggerHalt("Events.T1_4.Listen", "abcd", dispatcher, 199478));
280+
Assert.AreEqual(199479, n);
281+
Assert.AreEqual("abcd", s);
282+
}
283+
}
284+
}

src/CatLib.Core.Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525

2626
[assembly: Guid("3c9f4024-910c-4881-a04d-34a6c3a09019")]
2727

28-
[assembly: AssemblyVersion("1.2.5.0")]
29-
[assembly: AssemblyFileVersion("1.2.5.0")]
28+
[assembly: AssemblyVersion("1.2.6.0")]
29+
[assembly: AssemblyFileVersion("1.2.6.0")]

0 commit comments

Comments
 (0)