IRequiresConfiguration Interface
Marker interface for types that require a post-instantiation configuration step before they can be used.
public interface IRequiresConfigurationRemarks
Section titled “Remarks”Types implementing this interface signal to the dependency injection container
that after construction, a configuration method (by default named Configure)
must be called before any properties or methods are accessed. Attempting to access
a property before configuration raises a
TypeRequiresConfigurationAfterInstantiationException.
Properties
Section titled “Properties”IRequiresConfiguration.ConfigurationMethodName Property
Section titled “IRequiresConfiguration.ConfigurationMethodName Property”Gets the name of the method that must be called after instantiation to
configure this instance. Defaults to Configure.
string ConfigurationMethodName { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”IRequiresConfiguration.GetConfiguredProperty<T>(T, string) Method
Section titled “IRequiresConfiguration.GetConfiguredProperty<T>(T, string) Method”Returns field if it is not null; otherwise throws a TypeRequiresConfigurationAfterInstantiationException indicating that ConfigurationMethodName has not been called yet.
T GetConfiguredProperty<T>(T? field, string memberName);Type parameters
Section titled “Type parameters”T
The type of the property value.
Parameters
Section titled “Parameters”field T
The backing field to check.
memberName System.String
The name of the property being accessed, used in the exception message.