/// <inheritdoc /> public object GetOptions() { var provider = OptionsProvider ?? ConstructorProvider <TOptions> .CreateOrThrow(); object options; try { options = provider.GetInstance(); } catch (Exception ex) { throw ConfigurationExceptions.OptionsProviderFailed(typeof(TOptions), ex); } return(options ?? throw ConfigurationExceptions.OptionsProviderReturnedNull(typeof(TOptions))); }
/// <summary> /// Uses the default constructor provider for the options type. /// </summary> /// <returns>Configuration.</returns> /// <exception cref="Exception">No default constructor exists.</exception> public CommandConfiguration <TOptions> UseDefault() => Sink(ConstructorProvider <TOptions> .CreateOrThrow());
public void CreateOrThrowReturnsInstance() { ConstructorProvider <SomeType> .CreateOrThrow().ShouldNotBeNull(); }
public void ProviderCreatesInstance() { ConstructorProvider <SomeType> .CreateOrThrow().GetInstance().ShouldBeOfType <SomeType>(); }
public void ThrowsForNoDefaultConstructor() { Should.Throw <ConfigurationException>(() => ConstructorProvider <Parameterized> .CreateOrThrow()); }