public static ILogger <TType> GetLogger <TType>(this Splat.IDependencyResolver services) { ILogger <TType> logger = (ILogger <TType>)services.GetService(typeof(ILogger <TType>)); if (logger == null) { if (services is Splat.IMutableDependencyResolver mutableServices) { RegisterLogger <TType>(mutableServices); logger = (ILogger <TType>)services.GetService(typeof(ILogger <TType>)); } else { logger = new ReactiveLogger <TType>(); } } return(logger); }
public static ILogger GetLogger(this Splat.IDependencyResolver services, Type type) { var genericLogger = typeof(ILogger <>).MakeGenericType(type); ILogger logger = (ILogger)services.GetService(genericLogger); if (logger == null) { if (services is Splat.IMutableDependencyResolver mutableServices) { RegisterLogger(mutableServices, type); logger = (ILogger)services.GetService(genericLogger); } else { var genericReactiveLogger = typeof(ReactiveLogger <>).MakeGenericType(type); logger = (ILogger)Activator.CreateInstance(genericReactiveLogger); } } return(logger); }