internal static IServiceHostBuilder UseSerializer(this IServiceHostBuilder serviceHostBuilder) { serviceHostBuilder.RegisterService((containerBuilder) => { containerBuilder.RegisterType <Serializer>().As <ISerializer>().SingleInstance(); }); return(serviceHostBuilder); }
internal static IServiceHostBuilder UseLog4netLogger(this IServiceHostBuilder serviceHostBuilder, Log4netOptions options = null) { serviceHostBuilder.RegisterService(containerBuilder => { if (options == null) { options = new Log4netOptions(); } containerBuilder.RegisterType <Log4netLogger>().WithParameter("options", options).As <ILogger>().SingleInstance(); }); return(serviceHostBuilder); }
public static T UseLog4netLogger <T>(this IServiceHostBuilder serviceHostBuilder, LogOptions options = null) where T : class, IServiceHostBuilder { serviceHostBuilder.RegisterService(containerBuilder => { if (options == null) { options = new LogOptions(); } containerBuilder.RegisterType <Log4netLogger>().WithParameter("options", options).As <ILogger>().SingleInstance(); }); serviceHostBuilder.AddInitializer(container => { var logger = container.Resolve <ILogger>(); logger.Info($"[config]use Log4net logger"); }); return(serviceHostBuilder as T); }