Specifying a dedicated service instance for a singleton service
Normally, when hosting a WCF service, we only need to specify the service type in the
ServiceHost and the runtime will help create the service instance internally, according to the
InstanceContextMode we apply on the service class. This makes hosting a WCF service quite simple and convenient; the service developers do not need to know when and how the runtime creates the service instance. However, in some cases, it is useful and necessary to let the developer control when and how the service instance is created.
Singleton is one of the popular design patterns. This pattern can help design a class that will expose one and only one instance of the class over the entire lifecycle ...