Esempio n. 1
0
 /// <summary>
 /// Adds all the public JSON-RPC service types in the assembly of specified <see cref="Type"/>
 /// to the built <see cref="IJsonRpcServiceHost"/>.
 /// </summary>
 /// <typeparam name="T">A type. The search will be performed in the assembly where this type is in.</typeparam>
 public static IJsonRpcBuilder RegisterFromAssembly <T>(this IJsonRpcBuilder builder)
 {
     if (builder == null)
     {
         throw new ArgumentNullException(nameof(builder));
     }
     builder.Register(typeof(T).GetTypeInfo().Assembly);
     return(builder);
 }
Esempio n. 2
0
 /// <summary>
 /// Adds a JSON-RPC service to the built <see cref="IJsonRpcServiceHost"/>.
 /// </summary>
 /// <typeparam name="TService">The type of the service.</typeparam>
 public static IJsonRpcBuilder Register <TService>(this IJsonRpcBuilder builder) where TService : JsonRpcService
 {
     if (builder == null)
     {
         throw new ArgumentNullException(nameof(builder));
     }
     builder.Register(typeof(TService));
     return(builder);
 }
Esempio n. 3
0
 /// <summary>
 /// Adds all the public JSON-RPC service types in the assembly to the built <see cref="IJsonRpcServiceHost"/>.
 /// </summary>
 /// <param name="assembly">The assembly to search services in.</param>
 /// <exception cref="ArgumentNullException"><paramref name="assembly"/> is <c>null</c>.</exception>
 public static IJsonRpcBuilder Register(this IJsonRpcBuilder builder, Assembly assembly)
 {
     if (builder == null)
     {
         throw new ArgumentNullException(nameof(builder));
     }
     foreach (var t in assembly.ExportedTypes
              .Where(t => typeof(JsonRpcService).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo())))
     {
         builder.Register(t);
     }
     return(builder);
 }