public object GetService(Type serviceContract) { // check if the service is provided by this provider if (CanProvideService(serviceContract)) { return(null); } // create the channel var authenticationRequired = AuthenticationAttribute.IsAuthenticationRequired(serviceContract); var credentials = authenticationRequired ? new ChannelCredentials { UserName = this.UserName, Password = this.Password } : null; var channel = _channelProvider.GetPrimary(serviceContract, credentials); // create an AOP proxy around the channel, and return that return(CreateChannelProxy(serviceContract, channel)); }