/// <summary>Apply the behavior to the service end point.</summary>
        /// <param name="endpoint">The endpoint that exposes the contract.</param>
        /// <param name="endpointDispatcher">Endpoint dispatcher to which behaviors are applied.</param>
        public override void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            Debug.Assert(this.DomainDataServiceMetadata != null, "this.DomainDataServiceMetadata != null");
            this.serviceFactory = new DomainDataServiceFactory(this.DomainDataServiceMetadata);

            // Add operation to handle service document request.
            endpointDispatcher.DispatchRuntime.Operations.Add(
                new DispatchOperation(endpointDispatcher.DispatchRuntime, ServiceUtils.ServiceDocumentOperationName, null, null)
            {
                Invoker   = new NullOperationInvoker(),
                Formatter = new DomainDataServiceDispatchMessageFormatter(this.serviceFactory)
            });

            // Add operation to handle metadata request.
            endpointDispatcher.DispatchRuntime.Operations.Add(
                new DispatchOperation(endpointDispatcher.DispatchRuntime, ServiceUtils.MetadataOperationName, null, null)
            {
                Invoker   = new NullOperationInvoker(),
                Formatter = new DomainDataServiceDispatchMessageFormatter(this.serviceFactory)
            });

            // Add the base behavior.
            base.ApplyDispatchBehavior(endpoint, endpointDispatcher);
        }
        /// <summary>Apply the behavior to the service end point.</summary>
        /// <param name="endpoint">The endpoint that exposes the contract.</param>
        /// <param name="endpointDispatcher">Endpoint dispatcher to which behaviors are applied.</param>
        public override void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            Debug.Assert(this.DomainDataServiceMetadata != null, "this.DomainDataServiceMetadata != null");
            this.serviceFactory = new DomainDataServiceFactory(this.DomainDataServiceMetadata);

            // Add operation to handle service document request.
            endpointDispatcher.DispatchRuntime.Operations.Add(
                new DispatchOperation(endpointDispatcher.DispatchRuntime, ServiceUtils.ServiceDocumentOperationName, null, null)
                {
                    Invoker = new NullOperationInvoker(),
                    Formatter = new DomainDataServiceDispatchMessageFormatter(this.serviceFactory)
                });

            // Add operation to handle metadata request.
            endpointDispatcher.DispatchRuntime.Operations.Add(
                new DispatchOperation(endpointDispatcher.DispatchRuntime, ServiceUtils.MetadataOperationName, null, null)
                {
                    Invoker = new NullOperationInvoker(),
                    Formatter = new DomainDataServiceDispatchMessageFormatter(this.serviceFactory)
                });

            // Add the base behavior.
            base.ApplyDispatchBehavior(endpoint, endpointDispatcher);
        }
 /// <summary>
 /// Constructs an instance of message formatter for the domain data service end point.
 /// </summary>
 /// <param name="serviceFactory">Factory for creating domain data service instances.</param>
 public DomainDataServiceDispatchMessageFormatter(DomainDataServiceFactory serviceFactory)
 {
     this.serviceFactory = serviceFactory;
 }
 /// <summary>
 /// Constructs an instance of message formatter for the domain data service end point.
 /// </summary>
 /// <param name="serviceFactory">Factory for creating domain data service instances.</param>
 public DomainDataServiceDispatchMessageFormatter(DomainDataServiceFactory serviceFactory)
 {
     this.serviceFactory = serviceFactory;
 }