src/packages/EmbedIO/Routing/RouteVerbResolverCollection.cs
/// <summary>
/// <para>Adds handlers, associating them with HTTP method / route pairs by means
/// of <see cref="RouteAttribute">Route</see> attributes.</para>
/// <para>A compatible handler is a static or instance method that takes 2
/// parameters having the following types, in order:</para>
/// <list type="number">
/// <item><description><see cref="IHttpContext"/></description></item>
/// <item><description><see cref="RouteMatch"/></description></item>
/// </list>
/// <para>The return type of a compatible handler may be either <see langword="void"/>
/// or <see cref="Task"/>.</para>
/// <para>A compatible handler, in order to be added to a <see cref="RouteVerbResolverCollection"/>,
/// must have one or more <see cref="RouteAttribute">Route</see> attributes.
/// The same handler will be added once for each such attribute, either declared on the handler,
/// or inherited (if the handler is a virtual method).</para>
/// <para>This method behaves according to the type of the <paramref name="target"/>
/// parameter:</para>
/// <list type="bullet">
/// <item><description>if <paramref name="target"/> is a <see cref="Type"/>, all public static methods of
/// the type (either declared on the same type or inherited) that are compatible handlers will be added
/// to the collection;</description></item>
/// <item><description>if <paramref name="target"/> is an <see cref="Assembly"/>, all public static methods of
/// each exported type of the assembly (either declared on the same type or inherited) that are compatible handlers will be added
/// to the collection;</description></item>
/// <item><description>if <paramref name="target"/> is a <see cref="MethodInfo"/> referring to a compatible handler,
/// it will be added to the collection;</description></item>
/// <item><description>if <paramref name="target"/> is a <see langword="delegate"/> whose <see cref="Delegate.Method">Method</see>
/// refers to a compatible handler, that method will be added to the collection;</description></item>
/// <item><description>if <paramref name="target"/> is none of the above, all public instance methods of
/// its type (either declared on the same type or inherited) that are compatible handlers will be bound to <paramref name="target"/>
/// and added to the collection.</description></item>
/// </list>
/// </summary>
/// <param name="target">Where to look for compatible handlers. See the Summary section for more information.</param>
/// <returns>
/// <para>The number of handlers that were added to the collection.</para>
/// <para>Note that methods with multiple <see cref="RouteAttribute">Route</see> attributes
/// will count as one for each attribute.</para>
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="target"/> is <see langword="null"/>.</exception>
Adds handlers, associating them with HTTP method / route pairs by means
of RouteA compatible handler is a static or instance method that takes 2
parameters having the following types, in order:The return type of a compatible handler may be either
or .A compatible handler, in order to be added to a ,
must have one or more RouteThis method behaves according to the type of the
parameter:if  is a , all public static methods of
the type (either declared on the same type or inherited) that are compatible handlers will be added
to the collection;if  is an , all public static methods of
each exported type of the assembly (either declared on the same type or inherited) that are compatible handlers will be added
to the collection;if  is a  referring to a compatible handler,
it will be added to the collection;if  is a  whose Methodif  is none of the above, all public instance methods of
its type (either declared on the same type or inherited) that are compatible handlers will be bound to
and added to the collection.
Adds handlers associating them with HTTP method / route pairs by means of RouteA compatible handler is a static or instance method that takes 2 parameters having the following types in order : The return type of a compatible handler may be either or . A compatible handler in order to be added to a must have one or more RouteThis method behaves according to the type of the parameter : if is a all public static methods of the type ( either declared on the same type or inherited ) that are compatible handlers will be added to the collection ; if is an all public static methods of each exported type of the assembly ( either declared on the same type or inherited ) that are compatible handlers will be added to the collection ; if is a referring to a compatible handler it will be added to the collection ; if is a whose Methodif is none of the above all public instance methods of its type ( either declared on the same type or inherited ) that are compatible handlers will be bound to and added to the collection .
public int AddFrom(object target) => Validate.NotNull(nameof(target), target) switch {
            Type type => AddFrom(null, type),
            Assembly assembly => assembly.GetExportedTypes().Sum(t => AddFrom(null, t)),
            MethodInfo method => method.IsStatic ? Add(null, method) : 0,
            Delegate callback => Add(callback.Target, callback.Method),
            _ => AddFrom(target, target.GetType()),
        };
public int AddFrom ( object target ) => Validate . NotNull ( nameof ( target ) , target ) switch { Type type => AddFrom ( null , type ) , Assembly assembly => assembly . GetExportedTypes ( ) . Sum ( t => AddFrom ( null , t ) ) , MethodInfo method => method . IsStatic ? Add ( null , method ) : 0 , Delegate callback => Add ( callback . Target , callback . Method ) , _ => AddFrom ( target , target . GetType ( ) ) , } ;
Adds handlers, associating them with HTTP method / route pairs by means
of RouteA compatible handler is a static or instance method that takes 2
parameters having the following types, in order:The return type of a compatible handler may be either
or .A compatible handler, in order to be added to a ,
must have one or more RouteThis method behaves according to the type of the
parameter:if  is a , all public static methods of
the type (either declared on the same type or inherited) that are compatible handlers will be added
to the collection;if  is an , all public static methods of
each exported type of the assembly (either declared on the same type or inherited) that are compatible handlers will be added
to the collection;if  is a  referring to a compatible handler,
it will be added to the collection;if  is a  whose Methodif  is none of the above, all public instance methods of
its type (either declared on the same type or inherited) that are compatible handlers will be bound to
and added to the collection.
Adds handlers associating them with HTTP method / route pairs by means of RouteA compatible handler is a static or instance method that takes 2 parameters having the following types in order : The return type of a compatible handler may be either or . A compatible handler in order to be added to a must have one or more RouteThis method behaves according to the type of the parameter : if is a all public static methods of the type ( either declared on the same type or inherited ) that are compatible handlers will be added to the collection ; if is an all public static methods of each exported type of the assembly ( either declared on the same type or inherited ) that are compatible handlers will be added to the collection ; if is a referring to a compatible handler it will be added to the collection ; if is a whose Methodif is none of the above all public instance methods of its type ( either declared on the same type or inherited ) that are compatible handlers will be bound to and added to the collection .
The number of handlers that were added to the collection.Note that methods with multiple Route
The number of handlers that were added to the collection . Note that methods with multiple Route
None
target
object
None