How-To: Registering services through configuration in WCSF. Update!
After got valuable feedback of the community, we decided to change some things of the previous version.
In this new version we can define the scope of the service we are registering, allowing thus register global and module services. This version is a replacement of the previous one.
Here are the breaking changes:
- Remove the services section from the config file (We added this section in the previous version).
- Change the modules section:
Change this:
<sectionGroup name=”compositeWeb”> <section name=”modules” type=”Microsoft.Practices.CompositeWeb.Configuration.ModulesConfigurationSection, Microsoft.Practices.CompositeWeb”/> <!– Other config sections here –> </sectionGroup>To this:
<sectionGroup name=”compositeWeb”> <section name=”modules” type=”CompositeWeb.Extensions.Configuration.CustomModulesConfigurationSection, CompositeWeb.Extensions”/> <!– Other config sections here –> </sectionGroup>
- Changed the way of how register the services in the config files. Now we have to put the services node into the module node:
<module name=”Customers” assemblyName=”ModuleQuickstart.Customers” virtualPath=”~/Customers”> <services> <service registerAs=”MyInterfaces.IService1, MyInterfaces” type=”MyImplementations.Service1, MyImplementations”/> <service registerAs=”MyInterfaces.IService2, MyInterfaces” scope=”Global” type=”MyImplementations.Service2, MyImplementations”/> <service registerAs=”MyInterfaces.IService3, MyInterfaces” scope=”Module” type=”MyImplementations.Service3, MyImplementations”/> </services> </module>
Note: By default the services are registered as global services.
- Change the Global.asax file to inherits from CompositeWeb.Extensions.ExtendedWebClientApplication
<%@ Application Language=”C#” Inherits=”CompositeWeb.Extensions.ExtendedWebClientApplication” %>
Source code
- You can get the source code of the CompositeWeb.Extensions project by downloading the WCSF Extensions v1.0 release located at the new Codeplex WCSF Extensions project. If you face problems building the solution, make sure the references to the assemblies are correct.
- Important: The code is provided “as is” without warranty of any kind.