dazinator / CrmAdo

An ADO.NET Provider for Dynamics Crm
6 stars 4 forks source link

Dependency Injection - Adopt TinyIoC #51

Closed dazinator closed 9 years ago

dazinator commented 9 years ago

I am going to adopt TinyIoC as an IoC container.

CrmDbConnection will become the resolution root object.

I'll change CrmDbProviderFactory.CreateConnection() so that it resolves instances of CrmDbConnection from the container.

I'll allow consumers to bootstrap their own container and replace the default container.

In essence this will allow consumers to bootstrap their own implementations of services, which will end up injected into CrmDbConnection instances, assuming those instances are created by DbProviderFactory.

If the consumer is directly creating instances of CrmDbConnection then they are already in control of passing in their own services, via the constructor.

dazinator commented 9 years ago

Consumers of the CrmAdo library can now override CrmAdo default behaviours by implementing their own IContainerProvider that returns their own IContainer instance. They can register their IContainerProvider by calling CrmAdo.IoC.ContainerServices.SetContainerProvider