DiscoveryInnerClientManaged11.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Discovery / Version11 / DiscoveryInnerClientManaged11.cs / 1305376 / DiscoveryInnerClientManaged11.cs

                            //---------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------

namespace System.ServiceModel.Discovery.Version11 
{
    using System; 
    using System.ServiceModel; 
    using System.ServiceModel.Channels;
    using System.Runtime; 
    using System.ServiceModel.Description;

    class DiscoveryInnerClientManaged11 : ClientBase, IDiscoveryInnerClient
    { 
        IDiscoveryInnerClientResponse responseReceiver;
 
        internal DiscoveryInnerClientManaged11(DiscoveryEndpoint discoveryEndpoint, IDiscoveryInnerClientResponse responseReceiver) 
            : base(discoveryEndpoint)
        { 
            Fx.Assert(responseReceiver != null, "The responseReceiver parameter cannot be null");
            this.responseReceiver = responseReceiver;
        }
 
        public new ClientCredentials ClientCredentials
        { 
            get 
            {
                return base.ClientCredentials; 
            }
        }

        public new ChannelFactory ChannelFactory 
        {
            get 
            { 
                return base.ChannelFactory;
            } 
        }

        public new IClientChannel InnerChannel
        { 
            get
            { 
                return base.InnerChannel; 
            }
        } 

        public new ServiceEndpoint Endpoint
        {
            get 
            {
                return base.Endpoint; 
            } 
        }
 
        public ICommunicationObject InnerCommunicationObject
        {
            get
            { 
                return this as ICommunicationObject;
            } 
        } 

        public bool IsRequestResponse 
        {
            get
            {
                return true; 
            }
        } 
 
        public IAsyncResult BeginProbeOperation(FindCriteria findCriteria, AsyncCallback callback, object state)
        { 
            ProbeMessage11 request = new ProbeMessage11();
            request.Probe = FindCriteria11.FromFindCriteria(findCriteria);
            return base.Channel.BeginProbeOperation(request, callback, state);
        } 

        public IAsyncResult BeginResolveOperation(ResolveCriteria resolveCriteria, AsyncCallback callback, object state) 
        { 
            ResolveMessage11 request = new ResolveMessage11();
            request.Resolve = ResolveCriteria11.FromResolveCriteria(resolveCriteria); 

            return base.Channel.BeginResolveOperation(request, callback, state);
        }
 
        public void EndProbeOperation(IAsyncResult result)
        { 
            ProbeMatchesMessage11 response = base.Channel.EndProbeOperation(result); 
            AsyncOperationContext context = (AsyncOperationContext)result.AsyncState;
            if ((response != null) && (response.ProbeMatches != null)) 
            {
                this.responseReceiver.ProbeMatchOperation(
                    context.OperationId,
                    DiscoveryUtility.ToDiscoveryMessageSequenceOrNull(response.MessageSequence), 
                    DiscoveryUtility.ToEndpointDiscoveryMetadataCollection(response.ProbeMatches),
                    true); 
            } 
            else
            { 
                this.responseReceiver.PostFindCompletedAndRemove(context.OperationId, false, null);
            }
        }
 
        public void EndResolveOperation(IAsyncResult result)
        { 
            ResolveMatchesMessage11 response = base.Channel.EndResolveOperation(result); 
            AsyncOperationContext context = (AsyncOperationContext)result.AsyncState;
            if ((response != null) && (response.ResolveMatches != null) && (response.ResolveMatches.ResolveMatch != null)) 
            {
                this.responseReceiver.ResolveMatchOperation(
                    context.OperationId,
                    DiscoveryUtility.ToDiscoveryMessageSequenceOrNull(response.MessageSequence), 
                    response.ResolveMatches.ResolveMatch.ToEndpointDiscoveryMetadata());
            } 
            else 
            {
                this.responseReceiver.PostResolveCompletedAndRemove(context.OperationId, false, null); 
            }
        }

        public void ProbeOperation(FindCriteria findCriteria) 
        {
            ProbeMessage11 request = new ProbeMessage11(); 
            request.Probe = FindCriteria11.FromFindCriteria(findCriteria); 

            ProbeMatchesMessage11 response = base.Channel.ProbeOperation(request); 
            if ((response != null) && (response.ProbeMatches != null))
            {
                this.responseReceiver.ProbeMatchOperation(
                    OperationContext.Current.IncomingMessageHeaders.RelatesTo, 
                    DiscoveryUtility.ToDiscoveryMessageSequenceOrNull(response.MessageSequence),
                    DiscoveryUtility.ToEndpointDiscoveryMetadataCollection(response.ProbeMatches), 
                    true); 
            }
            else 
            {
                this.responseReceiver.PostFindCompletedAndRemove(OperationContext.Current.IncomingMessageHeaders.RelatesTo, false, null);
            }
        } 

        public void ResolveOperation(ResolveCriteria resolveCriteria) 
        { 
            ResolveMessage11 request = new ResolveMessage11();
            request.Resolve = ResolveCriteria11.FromResolveCriteria(resolveCriteria); 

            ResolveMatchesMessage11 response = base.Channel.ResolveOperation(request);
            if ((response != null) && (response.ResolveMatches != null) && (response.ResolveMatches.ResolveMatch != null))
            { 
                this.responseReceiver.ResolveMatchOperation(
                    OperationContext.Current.IncomingMessageHeaders.RelatesTo, 
                    DiscoveryUtility.ToDiscoveryMessageSequenceOrNull(response.MessageSequence), 
                    response.ResolveMatches.ResolveMatch.ToEndpointDiscoveryMetadata());
            } 
            else
            {
                this.responseReceiver.PostResolveCompletedAndRemove(OperationContext.Current.IncomingMessageHeaders.RelatesTo, false, null);
            } 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK