I'm trying to implement constructor injection for a generic type repository interface. I do this by applying http://msdn.microsoft.com/en-us/library/ff660933(v=pandp.20).aspx documentation. The xml-editor however does not accept the square brackets in for instance:
<alias alias="IGenericRepository"
type="Design.DataModel.Interfaces.IGenericRepository'1 [[Design.DataModel.Entities.GaugeModel, Design.DataModel]], Design.DataModel"/>
The xml-editor gives the following error: "Unexpected text". The full xml-section is:
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<sectionExtension prefix="" type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration" />
<alias alias="IGenericRepository" type="Design.DataModel.Interfaces.IGenericRepository'1[[Design.DataModel.Entities.GaugeModel, Design.DataModel]], Design.DataModel"/>
<alias alias="GenericSqlRepository" type="Design.DataAccess.GenericSqlRepository'1[[Design.DataModel.Entities.GaugeModel, Design.DataModel]], Design.DataAccess"/>
<alias alias="IGaugeModelbaseService" type="Design.Contracts.IGaugeModelbaseService, Design.Contracts"/>
<alias alias="GaugeModelbaseService" type="Design.ContractImplememtations.GaugeModelbaseService, Design.ContractImplementations"/>
<alias alias="IContractMapper" type="Design.ContractImplementations.IContractMapper, Design.ContractImplementations"/>
<alias alias="ContractMapper" type="Design.ContractImplementations.ContractMapper"/>
<container>
<register type="IGaugeModelbaseService" mapTo="GaugeModelbaseService">
<interceptor type="InterfaceInterceptor" />
</register>
<register type="IContractMapper" mapTo="ContractMapper">
<lifetime type="hierarchical" />
</register>
<register type="IGenericRepository" mapTo="GenericSqlRepository">
<lifetime type="hierarchical" />
</register>
</container>
Browsing the svc result however results in an error: "The type name or alias GaugeModelbaseService could not be resolved"
The xml must be equivalent to the folowing fluent API configuration (that works fine):
public class WcfServiceFactory : UnityServiceHostFactory
{
#region Methods
protected override void ConfigureContainer(IUnityContainer container)
{
//container.LoadConfiguration();
container.AddNewExtension<EnterpriseLibraryCoreExtension>();
container.AddNewExtension<Interception>();
container.RegisterType<IGaugeModelbaseService, GaugeModelbaseService>(
new InterceptionBehavior<PolicyInjectionBehavior>(), new Interceptor<TransparentProxyInterceptor>());
container.RegisterType<IContractMapper, ContractMapper>(new HierarchicalLifetimeManager());
container.RegisterType<IGenericRepository<GaugeModel>, GenericSqlRepository<GaugeModel>>(
new HierarchicalLifetimeManager());
}
#endregion
}
Do I miss something in the xml-configuration? Please help.