Skip to content

Commit

Permalink
resolved #111
Browse files Browse the repository at this point in the history
  • Loading branch information
ymh199478 committed Dec 13, 2018
1 parent 07bf6f3 commit b2501fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
11 changes: 0 additions & 11 deletions src/CatLib.Core/Support/Container/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,17 +585,6 @@ public object this[string service]
}
}

/// <summary>
/// 获取一个回调,当执行回调可以生成指定的服务
/// </summary>
/// <param name="service">服务名或别名</param>
/// <param name="userParams">用户传入的参数</param>
/// <returns>回调方案</returns>
public Func<object> Factory(string service, params object[] userParams)
{
return () => Make(service, userParams);
}

/// <summary>
/// 扩展容器中的服务
/// <para>允许在服务构建的过程中配置或者替换服务</para>
Expand Down
12 changes: 12 additions & 0 deletions src/CatLib.Core/Support/Container/ContainerExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,5 +1020,17 @@ public static string Type2Service<TService>(this IContainer container)
{
return container.Type2Service(typeof(TService));
}

/// <summary>
/// 获取一个回调,当执行回调可以生成指定的服务
/// </summary>
/// <param name="container">服务容器</param>
/// <param name="service">服务名或别名</param>
/// <param name="userParams">用户传入的参数</param>
/// <returns>回调方案</returns>
public static Func<object> Factory(this IContainer container, string service, params object[] userParams)
{
return () => container.Make(service, userParams);
}
}
}
8 changes: 0 additions & 8 deletions src/CatLib.Core/Support/Container/IContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ public interface IContainer
/// <returns>服务实例,如果构造失败那么返回null</returns>
object this[string service] { get; set; }

/// <summary>
/// 获取一个回调,当执行回调可以生成指定的服务
/// </summary>
/// <param name="service">服务名或别名</param>
/// <param name="userParams">用户传入的参数</param>
/// <returns>回调方案</returns>
Func<object> Factory(string service, params object[] userParams);

/// <summary>
/// 为服务设定一个别名
/// </summary>
Expand Down

0 comments on commit b2501fb

Please sign in to comment.