Skip to content

Commit

Permalink
【6.6.14】单例注册已生成的实例 | Singleton registration of generated instances
Browse files Browse the repository at this point in the history
  • Loading branch information
yomunsam committed Oct 7, 2020
1 parent c3d3711 commit 80074ed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Runtime/Scripts/Interfaces/IServiceContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public interface IServiceContainer
IBindData BindBuiltInService<TBuiltInService, TService, TConcrete>() where TBuiltInService : IBuiltInService;
IBindData BindBuiltInService<TBuiltInService, TConcrete>() where TBuiltInService : IBuiltInService;

object Instance(string service, object instance);
object Instance<TService>(object instance);

#endregion

#region Unbind Services
Expand All @@ -88,5 +91,6 @@ public interface IServiceContainer

string Type2ServiceName(Type type);
string Type2ServiceName<TService>();

}
}
17 changes: 17 additions & 0 deletions Runtime/Scripts/ServiceContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ public IBindData BindBuiltInService<TBuiltInService, TConcrete>() where TBuiltIn
return CatApplication.Singleton<TBuiltInService, TConcrete>();
}

/// <summary>
/// 单例注册已生成的实例 | Singleton registration of generated instances
/// </summary>
/// <typeparam name="TService"></typeparam>
/// <param name="instance"></param>
/// <returns></returns>
public object Instance<TService>(object instance)
=> CatApplication.Instance<TService>(instance);

/// <summary>
/// 单例注册已生成的实例 | Singleton registration of generated instances
/// </summary>
/// <param name="service"></param>
/// <param name="instance"></param>
/// <returns></returns>
public object Instance(string service, object instance)
=> CatApplication.Instance(service, instance);

#endregion

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "io.nekonya.tinax.core",
"version": "6.6.13",
"version": "6.6.14",
"displayName": "TinaX.Core",
"description": "TinaX Framework.",
"unity": "2019.4",
Expand Down

0 comments on commit 80074ed

Please sign in to comment.