void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            if (serviceDescription == null)
            {
                throw FxTrace.Exception.ArgumentNull("serviceDescription");
            }
            if (serviceHostBase == null)
            {
                throw FxTrace.Exception.ArgumentNull("serviceHostBase");
            }

            List<ServiceEndpoint> appEndpoints = this.GetApplicationEndpoints(serviceDescription);

            DiscoveryServiceExtension discoveryServiceExtension = 
                serviceHostBase.Extensions.Find<DiscoveryServiceExtension>();

            if (discoveryServiceExtension == null)
            {
                if (serviceDescription.Endpoints.Count > appEndpoints.Count)
                {
                    discoveryServiceExtension = 
                        new DefaultDiscoveryServiceExtension(DiscoveryDefaults.DuplicateMessageHistoryLength);
                }
                else
                {
                    discoveryServiceExtension = 
                        new DefaultDiscoveryServiceExtension(0);
                }

                serviceHostBase.Extensions.Add(discoveryServiceExtension);
            }            

            for (int i = 0; i < appEndpoints.Count; i++)
            {
                appEndpoints[i].Behaviors.Add(
                    new EndpointDiscoveryMetadataInitializer(
                    discoveryServiceExtension.InternalPublishedEndpoints));
            }
        }
        void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            if (serviceDescription == null)
            {
                throw FxTrace.Exception.ArgumentNull("serviceDescription");
            }
            if (serviceHostBase == null)
            {
                throw FxTrace.Exception.ArgumentNull("serviceHostBase");
            }

            List <ServiceEndpoint> appEndpoints = this.GetApplicationEndpoints(serviceDescription);

            DiscoveryServiceExtension discoveryServiceExtension =
                serviceHostBase.Extensions.Find <DiscoveryServiceExtension>();

            if (discoveryServiceExtension == null)
            {
                if (serviceDescription.Endpoints.Count > appEndpoints.Count)
                {
                    discoveryServiceExtension =
                        new DefaultDiscoveryServiceExtension(DiscoveryDefaults.DuplicateMessageHistoryLength);
                }
                else
                {
                    discoveryServiceExtension =
                        new DefaultDiscoveryServiceExtension(0);
                }

                serviceHostBase.Extensions.Add(discoveryServiceExtension);
            }

            for (int i = 0; i < appEndpoints.Count; i++)
            {
                appEndpoints[i].Behaviors.Add(
                    new EndpointDiscoveryMetadataInitializer(
                        discoveryServiceExtension.InternalPublishedEndpoints));
            }
        }