コード例 #1
0
 /// <summary>
 /// Subscribes automatically methods of a Type marked with the <see cref="SubscribeAttribute"/> on an <see cref="IPublisher"/> instance.
 /// </summary>
 /// <param name="publisher">The <see cref="IPublisher"/> instance.</param>
 /// <param name="type">The type.</param>
 /// <returns>A <see cref="IDisposable"/> to unregister.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="publisher"/> or <paramref name="type"/> is null.</exception>
 /// <exception cref="NotSupportedException"><see cref="SubscribeAttribute"/> is used on an uncompatible method of the instance.</exception>
 public static IDisposable Subscribe(this IPublisher publisher, Type type)
 {
     return(Subscribe(
                publisher.CheckArgumentNullException(nameof(publisher)),
                type.CheckArgumentNullException(nameof(type)),
                null));
 }
コード例 #2
0
 /// <summary>
 /// Subscribes automatically methods of an instance and its Type marked with the <see cref="SubscribeAttribute"/> on an <see cref="IPublisher"/> instance.
 /// </summary>
 /// <typeparam name="T">The Type.</typeparam>
 /// <param name="publisher">The <see cref="IPublisher"/> instance.</param>
 /// <param name="target">The instance.</param>
 /// <returns>A <see cref="IDisposable"/> to unregister.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="publisher"/> or <paramref name="target"/> is null.</exception>
 /// <exception cref="NotSupportedException"><see cref="SubscribeAttribute"/> is used on an uncompatible method of the instance.</exception>
 public static IDisposable Subscribe <T>(this IPublisher publisher, T target)
     where T : class
 {
     return(Subscribe(
                publisher.CheckArgumentNullException(nameof(publisher)),
                target.CheckArgumentNullException(nameof(target)).GetType(),
                target));
 }