private void ValidateContractType(System.Type implementedContract, ReflectedAndBehaviorContractCollection reflectedAndBehaviorContracts)
 {
     if (!implementedContract.IsDefined(typeof(ServiceContractAttribute), false))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SfxServiceContractAttributeNotFound", new object[] { implementedContract.FullName })));
     }
     if (!reflectedAndBehaviorContracts.Contains(implementedContract))
     {
         if (implementedContract == typeof(IMetadataExchange))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SfxReflectedContractKeyNotFoundIMetadataExchange", new object[] { this.serviceType.FullName })));
         }
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SfxReflectedContractKeyNotFound2", new object[] { implementedContract.FullName, this.serviceType.FullName })));
     }
 }
        public ServiceEndpoint AddServiceEndpoint(System.Type implementedContract, Binding binding, Uri address, Uri listenUri)
        {
            if (implementedContract == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("implementedContract"));
            }
            if (this.reflectedContracts == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SfxReflectedContractsNotInitialized1", new object[] { implementedContract.FullName })));
            }
            ReflectedAndBehaviorContractCollection reflectedAndBehaviorContracts = new ReflectedAndBehaviorContractCollection(this.reflectedContracts, base.Description.Behaviors);

            this.ValidateContractType(implementedContract, reflectedAndBehaviorContracts);
            ServiceEndpoint endpoint = base.AddServiceEndpoint(reflectedAndBehaviorContracts.GetConfigKey(implementedContract), binding, address);

            if (listenUri != null)
            {
                listenUri          = base.MakeAbsoluteUri(listenUri, binding);
                endpoint.ListenUri = listenUri;
            }
            return(endpoint);
        }