Common service locator Library

Source: Internet
Author: User

have you applied the IOC container in your Program ? Do you want to depend on a specific IOC, the common service locator released by Microsoft's mode and practice team on codeplex. The common service locator class library contains an interface for application and framework developers to reference service location sharing. This class library is abstracted on the IOC container and service locators. This class library allows an application to indirectly access without strong reference dependencies. The interface it defines is very simple:

namespace Microsoft. practices. servicelocation
{< br> Public interface iservicelocator: iserviceprovider
{< br> Object getinstance (type servicetype );
Object getinstance (type servicetype, string key );
ienumerable Object getallinstances (type servicetype);
tservice getinstance ();
tservice getinstance ( string key);
ienumerable getallinstances ();
}< BR >}

 
 

A servicelocator static class is also provided as a single access point:

NamespaceMicrosoft. Practices. servicelocation
{
Public Static ClassServicelocator
{
Private StaticServicelocatorprovider currentprovider;

Public StaticIservicelocator current
{
Get {ReturnCurrentprovider ();}
}

Public Static VoidSetlocatorprovider (servicelocatorprovider newprovider)
{
Currentprovider = newprovider;
}
}
}

 
 

Here, the server locator is used to remove the dependency between IOC and components. The most basic idea of a service locator is that an object locator knows how to control all services required by an application. The website now has

 
 

Commonly used IOC adapters. If you use castle, you can use Castle Windsor adaptor. If you are using unity, you can use unity adapter and spring. Net adapter,

 
 

Structuremap adapter and so on.

 
 

common service locator official: http://www.codeplex.com/CommonServiceLocator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.