예제 #1
0
        public static IMyLoggerProviderBuilder AddMyLoggerProvider <T>(this IMyLoggerProviderBuilder builder, string name) where T : class, IMyLoggerProvider
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            return(builder.Add(new MyLoggerProviderRegistration(name, s => ActivatorUtilities.GetServiceOrCreateInstance <T>(s))));
        }
예제 #2
0
        public static IMyLoggerProviderBuilder AddMyLoggerProvider(this IMyLoggerProviderBuilder builder, string name, IMyLoggerProvider instance)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

            return(builder.Add(new MyLoggerProviderRegistration(name, instance)));
        }
예제 #3
0
        public static IMyLoggerProviderBuilder AddMyLoggerProvider(this IMyLoggerProviderBuilder builder, string name, Func <IServiceProvider, string, IMyLoggerProvider> factory)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (factory is null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            return(builder.Add(new MyLoggerProviderRegistration(name, s => factory(s, name))));
        }