@@ -789,7 +789,7 @@ public static void Extend(this IContainer container, string service, Func<object
789789 /// <param name="closure">闭包</param>
790790 public static void Extend < TService , TConcrete > ( this IContainer container , Func < TConcrete , object > closure )
791791 {
792- container . Extend ( container . Type2Service ( typeof ( TService ) ) , ( instance , c ) => closure ( ( TConcrete ) instance ) ) ;
792+ container . Extend ( container . Type2Service ( typeof ( TService ) ) , ( instance , c ) => closure ( ( TConcrete ) instance ) ) ;
793793 }
794794
795795 /// <summary>
@@ -802,7 +802,7 @@ public static void Extend<TService, TConcrete>(this IContainer container, Func<T
802802 public static void Extend < TService , TConcrete > ( this IContainer container , Func < TConcrete , IContainer , object > closure )
803803 {
804804 container . Extend ( container . Type2Service ( typeof ( TService ) ) ,
805- ( instance , c ) => closure ( ( TConcrete ) instance , c ) ) ;
805+ ( instance , c ) => closure ( ( TConcrete ) instance , c ) ) ;
806806 }
807807
808808 /// <summary>
@@ -1001,61 +1001,6 @@ public static IContainer OnAfterResolving<T>(this IContainer container, Action<I
10011001 } ) ;
10021002 }
10031003
1004- /// <summary>
1005- /// 关注指定的服务,当服务触发重定义时调用指定对象的指定方法
1006- /// <para>调用是以依赖注入的形式进行的</para>
1007- /// <para>服务的新建(第一次解决服务)操作并不会触发重定义</para>
1008- /// </summary>
1009- /// <param name="container">服务容器</param>
1010- /// <param name="service">关注的服务名</param>
1011- /// <param name="target">当服务发生重定义时调用的目标</param>
1012- /// <param name="methodInfo">方法信息</param>
1013- public static void Watch ( this IContainer container , string service , object target , MethodInfo methodInfo )
1014- {
1015- Guard . Requires < ArgumentNullException > ( methodInfo != null ) ;
1016-
1017- if ( ! methodInfo . IsStatic )
1018- {
1019- Guard . Requires < ArgumentNullException > ( target != null ) ;
1020- }
1021-
1022- container . OnRebound ( service , ( instance ) =>
1023- {
1024- container . Call ( target , methodInfo , instance ) ;
1025- } ) ;
1026- }
1027-
1028- /// <summary>
1029- /// 关注指定的服务,当服务触发重定义时调用指定对象的指定方法
1030- /// <param>调用是以依赖注入的形式进行的</param>
1031- /// </summary>
1032- /// <param name="container">服务容器</param>
1033- /// <param name="service">关注的服务名</param>
1034- /// <param name="target">当服务发生重定义时调用的目标</param>
1035- /// <param name="method">方法名</param>
1036- public static void Watch ( this IContainer container , string service , object target , string method )
1037- {
1038- Guard . Requires < ArgumentNullException > ( target != null ) ;
1039- Guard . NotEmptyOrNull ( method , nameof ( method ) ) ;
1040-
1041- var methodInfo = target . GetType ( ) . GetMethod ( method ) ;
1042- container . Watch ( service , target , methodInfo ) ;
1043- }
1044-
1045- /// <summary>
1046- /// 关注指定的服务,当服务触发重定义时调用指定对象的指定方法
1047- /// <param>调用是以依赖注入的形式进行的</param>
1048- /// </summary>
1049- /// <typeparam name="TService">服务名</typeparam>
1050- /// <param name="container">服务容器</param>
1051- /// <param name="target">当服务发生重定义时调用的目标</param>
1052- /// <param name="method">方法名</param>
1053- public static void Watch < TService > ( this IContainer container , object target , string method )
1054- {
1055- Guard . Requires < ArgumentNullException > ( method != null ) ;
1056- container . Watch ( container . Type2Service ( typeof ( TService ) ) , target , method ) ;
1057- }
1058-
10591004 /// <summary>
10601005 /// 关注指定的服务,当服务触发重定义时调用指定对象的指定方法
10611006 /// <param>调用是以依赖注入的形式进行的</param>
@@ -1066,7 +1011,7 @@ public static void Watch<TService>(this IContainer container, object target, str
10661011 public static void Watch < TService > ( this IContainer container , Action method )
10671012 {
10681013 Guard . Requires < ArgumentNullException > ( method != null ) ;
1069- container . Watch ( container . Type2Service ( typeof ( TService ) ) , method . Target , method . Method ) ;
1014+ container . OnRebound ( container . Type2Service ( typeof ( TService ) ) , ( instance ) => method ( ) ) ;
10701015 }
10711016
10721017 /// <summary>
@@ -1079,7 +1024,7 @@ public static void Watch<TService>(this IContainer container, Action method)
10791024 public static void Watch < TService > ( this IContainer container , Action < TService > method )
10801025 {
10811026 Guard . Requires < ArgumentNullException > ( method != null ) ;
1082- container . Watch ( container . Type2Service ( typeof ( TService ) ) , method . Target , method . Method ) ;
1027+ container . OnRebound ( container . Type2Service ( typeof ( TService ) ) , ( instance ) => method ( ( TService ) instance ) ) ;
10831028 }
10841029
10851030 /// <summary>
0 commit comments