public ConfigureWeatherForecastControllerOptions(IServiceProvider serviceProvider) { _stringGetter = serviceProvider.GetRequiredService <IStringGetter>(); var loggerFactory = serviceProvider.GetService <ILoggerFactory>() ?? new NullLoggerFactory(); _logger = loggerFactory.CreateLogger <WeatherForecastController>(); }
public DynamicProperty(IStringGetter getter, IStringSetter setter) { Ensure.That(getter, "getter").IsNotNull(); Ensure.That(setter, "setter").IsNotNull(); Getter = getter; Setter = setter; }
public DynamicProperty(string name, IStringGetter getter, IStringSetter setter) { Ensure.That(name, "name").IsNotNullOrWhiteSpace(); Ensure.That(getter, "getter").IsNotNull(); Ensure.That(setter, "setter").IsNotNull(); Name = name; Getter = getter; Setter = setter; }
public DynamicProperty(string name, IStringGetter getter, IStringSetter setter) { Ensure.String.IsNotNullOrWhiteSpace(name, nameof(name)); Ensure.Any.IsNotNull(getter, nameof(getter)); Ensure.Any.IsNotNull(setter, nameof(setter)); Name = name; Getter = getter; Setter = setter; }
//CN -- The object doesn't really *need* to know that IStringGetter is being injected // as a singleton or as a transient service - provided its needs are being met everything // should be cool. public DependencyInjection_EasyToTestSingleton(IStringGetter stringGetter) { _stringGetter = stringGetter ?? throw new ArgumentNullException(nameof(stringGetter)); }
public WeatherForecastController(IOptions <WeatherForecastControllerOptions> options) { _logger = options.Value.Logger; _summaryGetter = options.Value.StringGetter; }