public static IServiceCollection AddService( this IServiceCollection services, Type implementationType, Symbol scope, ServiceAttributeBase?defaultServiceAttribute = null) { var attrs = ServiceAttributeBase.GetAll(implementationType, a => a.Scope == scope); if (attrs.Length != 0) { foreach (var attr in attrs) { attr.Register(services, implementationType); } } else if (defaultServiceAttribute != null) { defaultServiceAttribute.Register(services, implementationType); } else { throw Errors.NoServiceAttribute(implementationType); } return(services); }
public static IServiceCollection AddService( this IServiceCollection services, Type implementationType, ServiceAttributeBase?defaultServiceAttribute = null) { var attr = ServiceAttributeBase.Get(implementationType) ?? defaultServiceAttribute; if (attr == null) { throw Errors.NoServiceAttribute(implementationType); } attr.Register(services, implementationType); return(services); }