Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

允许在Needs时提供需求的变量名,以支持变量名需求,改善变量名上下文关系的流程 #122

Closed
ymh199478 opened this issue Dec 18, 2018 · 0 comments
Labels

Comments

@ymh199478
Copy link
Contributor

ymh199478 commented Dec 18, 2018

  • 不再支持@作为变量标签,应该使用$替代。
  • 变量名不再会自动映射成服务名(都需要手动给定上下文),因为这会带来一些潜在的问题。
App.Bind<IService,Service>()
      .Needs("$params")
      .Given(()=> new object());

新增虚函数

/// <summary>
/// 根据上下文获取相关的构建闭包
/// </summary>
/// <param name="makeServiceBindData">请求注入操作的服务绑定数据</param>
/// <param name="service">服务名</param>
/// <param name="paramName">目标参数名</param>
/// <returns>构建闭包</returns>
protected virtual Func<object> GetContextualClosure(Bindable makeServiceBindData, string service,
            string paramName);
/// <summary>
/// 从上下文闭包中进行构建获得实例
/// </summary>
/// <param name="closure">上下文闭包</param>
/// <param name="needType">参数需求的类型</param>
/// <param name="ouput">构建的实例</param>
/// <returns>是否成功构建</returns>
protected virtual bool MakeFromContextualClosure(Func<object> closure, Type needType, out object ouput);
/// <summary>
/// 根据上下文获取相关的需求服务
/// </summary>
/// <param name="makeServiceBindData">请求注入操作的服务绑定数据</param>
/// <param name="service">构建的服务名</param>
/// <param name="paramName">目标参数的名字</param>
/// <returns>需求的服务名</returns>
protected virtual string GetContextualService(Bindable makeServiceBindData, string service, string paramName);
/// <summary>
/// 从上下文关系的服务名获取服务实现
/// </summary>
/// <param name="service">上下文关系的服务名</param>
/// <param name="needType">参数需求类型</param>
/// <param name="output">构建的实例</param>
/// <returns>是否成功构建</returns>
protected virtual bool MakeFromContextualService(string service, Type needType, out object output);
/// <summary>
/// 根据上下文来解决指定需求的服务
/// </summary>
/// <param name="makeServiceBindData">请求注入操作的服务绑定数据</param>
/// <param name="service">构建的服务名字</param>
/// <param name="paramName">目标参数的名字</param>
/// <param name="paramType">目标参数的类型</param>
/// <param name="output">构建的实例</param>
/// <returns>是否成功通过上下文解决</returns>
protected virtual bool ResloveFromContextual(Bindable makeServiceBindData, string service, string paramName, Type paramType, out object output);
ymh199478 added a commit that referenced this issue Dec 18, 2018
@ymh199478 ymh199478 changed the title 允许在Needs时提供需求的变量名,以支持变量名需求 允许在Needs时提供需求的变量名,以支持变量名需求,改善变量名上下文关系的流程 Dec 18, 2018
ymh199478 added a commit that referenced this issue Dec 18, 2018
@ymh199478 ymh199478 added the 1.3 label Dec 18, 2018
ymh199478 added a commit that referenced this issue Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant