protected T CreateChannelFactoryInterface<T>(string endpointName)
{
if (_hostAddress.Length > 0)
{
//Remoting Service
return (T)Activator.GetObject(typeof(T), _hostAddress);
}
else
{
//WCF Service
ChannelFactory<T> serviceChannel = new ChannelFactory<T>(endpointName);
//create the channel from the proxy
if (serviceChannel == null)
{
//TODO: throw custom exception
throw new ApplicationException("The service channel could not be created.");
}
return serviceChannel.CreateChannel();
}
}
[EndpointName("Clueless.ServiceHost.Artifact.Service.PPAT.IGlossaryTermContract")]
public Clueless.Contracts.PPAT.ArtifactContext.IGlossaryTermContract PPATGlossaryTerm
{
get
{
return base.CreateChannelFactoryInterface<Clueless.Contracts.PPAT.ArtifactContext.IGlossaryTermContract>(getEndpointName("PPATGlossaryTerm"));
}
}
[EndpointName("Clueless.ServiceHost.Entity.Service.PVP.IEntityLoginContract")]
public Clueless.Contracts.PVP.EntityContext.IEntityLoginContract PVPEntityLogin
{
get
{
//examine debug host address
if (base._hostAddress.Length > 0)
{
//Remoting Service - used for debugging
return
(Clueless.Contracts.PVP.EntityContext.IEntityLoginContract)Activator.GetObject
(typeof(Clueless.Contracts.PVP.EntityContext.IEntityLoginContract), base._hostAddress);
}
else
{
//WCF Service
ChannelFactory<Clueless.Contracts.PVP.EntityContext.IEntityLoginContract> serviceChannel =
new ChannelFactory<Clueless.Contracts.PVP.EntityContext.IEntityLoginContract>
(base.getEndpointName("PVPEntityLogin"));
//create the channel from the proxy
if (serviceChannel == null)
{
//throw exception - channel could nto be established
throw new ServiceChannelException(string.Format(
ServiceChannelException.MSG_NOTFOUND,
"Entity.Service.PVP.IEntityLoginContract"));
}
return serviceChannel.CreateChannel();
}
}
}