/// <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)));
        }
Exemplo n.º 2
0
 /// <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());
Exemplo n.º 3
0
 public void CreateOrThrowReturnsInstance()
 {
     ConstructorProvider <SomeType> .CreateOrThrow().ShouldNotBeNull();
 }
Exemplo n.º 4
0
 public void ProviderCreatesInstance()
 {
     ConstructorProvider <SomeType> .CreateOrThrow().GetInstance().ShouldBeOfType <SomeType>();
 }
Exemplo n.º 5
0
 public void ThrowsForNoDefaultConstructor()
 {
     Should.Throw <ConfigurationException>(() => ConstructorProvider <Parameterized> .CreateOrThrow());
 }