Skip to content

Commit 5dc2d1c

Browse files
committed
resolved #129
1 parent cde2c94 commit 5dc2d1c

File tree

6 files changed

+15
-54
lines changed

6 files changed

+15
-54
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
</ItemGroup>
3636
<ItemGroup>
3737
<Compile Include="CatLib\ApplicationTests.cs" />
38-
<Compile Include="CatLib\AppTests.cs" />
3938
<Compile Include="CatLib\FacaedTests.cs" />
4039
<Compile Include="CatLib\GlobalDispatcherTests.cs" />
4140
<Compile Include="CatLib\TypeExtendTests.cs" />

src/CatLib.Core.Tests/CatLib/AppTests.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/CatLib.Core.Tests/CatLib/ApplicationTests.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,16 @@ public void TestTerminate()
242242
Assert.AreEqual(1, num++);
243243
});
244244
App.Terminate();
245-
Assert.AreNotEqual(oldApp, App.Handler);
245+
var isCall = false;
246+
try
247+
{
248+
Assert.AreNotEqual(oldApp, App.Handler);
249+
}
250+
catch (LogicException)
251+
{
252+
isCall = true;
253+
}
254+
Assert.AreEqual(true, isCall);
246255
Assert.AreEqual(2, num);
247256
}
248257

src/CatLib.Core.Tests/CatLib/TypeExtendTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class TypeExtendTests
1919
[TestMethod]
2020
public void TestGetService()
2121
{
22+
var app = new Application();
2223
Assert.AreEqual(App.Type2Service<TypeExtendTests>(), typeof(TypeExtendTests).ToService());
2324
}
2425
}

src/CatLib.Core/CatLib/App.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,25 @@ public static event Action<IApplication> OnNewApplication
4848
/// </summary>
4949
private static IApplication instance;
5050

51-
/// <summary>
52-
/// 自动生成Application
53-
/// </summary>
54-
public static bool AutoInstance { get; set; } = true;
55-
5651
/// <summary>
5752
/// CatLib实例
5853
/// </summary>
5954
public static IApplication Handler
6055
{
6156
get
6257
{
63-
if (instance == null && !AutoInstance)
58+
if (instance == null)
6459
{
65-
throw new LogicException("The Application does not instance");
60+
throw new LogicException("The Application does not created, please call new Application() first.");
6661
}
67-
return instance ?? New();
62+
return instance;
6863
}
6964
set
7065
{
7166
instance = value;
7267
onNewApplication?.Invoke(instance);
7368
}
7469
}
75-
76-
/// <summary>
77-
/// 创建CatLib实例
78-
/// </summary>
79-
/// <returns>CatLib实例</returns>
80-
protected static IApplication New()
81-
{
82-
return Application.New();
83-
}
8470
#endregion
8571

8672
#region Application API

src/CatLib.Core/Support/Container/IGivenData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace CatLib
1616
/// <summary>
1717
/// 绑定关系临时数据,用于支持链式调用
1818
/// </summary>
19+
/// <typeparam name="TReturn">返回类型</typeparam>
1920
public interface IGivenData<TReturn>
2021
{
2122
/// <summary>

0 commit comments

Comments
 (0)