I am trying to use Autofac and register the below class which receives one of the parameter as optional parameter (or rather null). My classes are:
class BaseSpanRecord : ISpanRecord
{
public BaseSpanRecord(RecordType recordType, List<SpanRecordAttribute> properties)
{
RecordType = recordType;
Properties = properties;
}
}
Here RecordType is an enum and SpanRecordAttribute is a class with only properties for which i don't want to create any interface.
In the constructor RecordType and Properties are the two public properties of the interface ISpanRecord This class can be instantiated in the following ways in different places in the program:
ISpanRecord spanFileRecord = new BaseSpanRecord(recordType, null);
or
ISpanRecord spanFileRecord = new BaseSpanRecord(recordType, recordAttributeList);
How should i try to register this in the Autofac container so that it can handle the above two cases? Or should i change something in the way BaseSpanRecord class has been written to make its registration easier?