Func is a delegate without a parameter and with a return value of IVisitorRepository.
() => is a lambda expression that creates an anonymous method.
new VisitorRepository () is the content of this anonymous method.
therefore, this line creates a delegate that points to an anonymous method that returns an instance of VisitorRepository.
Func<IVisitorRepository> builder = () => new VisitorRepository()
In the next line, you set the value of the static property to the newly created delegate.
VisitorRepositoryFactory.RepositoryBuilder = builder;
After that, you can use the property to call an anonymous method that creates a new instance of VisitorRepository.
IVisitorRepository repository = VisitorRepositoryFactory.RepositoryBuilder();
In this case, the repository will be an instance of VisitorRepository.
Enyra source share