Beispiel #1
0
        RealProxy ICreateServiceChannel.CreateChannel()
        {
            if (serviceProxy == null)
            {
                lock (this)
                {
                    if (serviceProxy == null)
                    {
                        try
                        {
                            if (serviceChannelFactory == null)
                            {
                                FaultInserviceChannelFactory();
                            }

                            if (serviceChannelFactory == null)
                            {
                                throw Fx.AssertAndThrow("ServiceChannelFactory cannot be null at this point");
                            }

                            serviceChannelFactory.Open();

                            if (contractType == null)
                            {
                                throw Fx.AssertAndThrow("contractType cannot be null");
                            }
                            if (serviceEndpoint == null)
                            {
                                throw Fx.AssertAndThrow("serviceEndpoint cannot be null");
                            }

                            object transparentProxy = serviceChannelFactory.CreateChannel(contractType, new EndpointAddress(serviceEndpoint.Address.Uri, serviceEndpoint.Address.Identity, serviceEndpoint.Address.Headers), serviceEndpoint.Address.Uri);

                            ComPlusChannelCreatedTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationChannelCreated,
                                                             SR.TraceCodeComIntegrationChannelCreated, serviceEndpoint.Address.Uri, contractType);

                            RealProxy localProxy = RemotingServices.GetRealProxy(transparentProxy);

                            serviceProxy = localProxy;

                            if (serviceProxy == null)
                            {
                                throw Fx.AssertAndThrow("serviceProxy MUST derive from RealProxy");
                            }
                        }
                        finally
                        {
                            if ((serviceProxy == null) && (serviceChannelFactory != null))
                            {
                                serviceChannelFactory.Close();
                            }
                        }
                    }
                }
            }
            return(serviceProxy);
        }
        ServiceChannel CreateChannel()
        {
            if (serviceChannel == null)
            {
                lock (this)
                {
                    if (serviceChannel == null)
                    {
                        try
                        {
                            if (serviceChannelFactory == null)
                            {
                                FaultInserviceChannelFactory();
                            }

                            if (serviceChannelFactory == null)
                            {
                                throw Fx.AssertAndThrow("ServiceChannelFactory cannot be null at this point");
                            }

                            serviceChannelFactory.Open();

                            if (serviceEndpoint == null)
                            {
                                throw Fx.AssertAndThrow("ServiceEndpoint cannot be null");
                            }

                            ServiceChannel localChannel = serviceChannelFactory.CreateServiceChannel(new EndpointAddress(serviceEndpoint.Address.Uri, serviceEndpoint.Address.Identity, serviceEndpoint.Address.Headers), serviceEndpoint.Address.Uri);
                            serviceChannel = localChannel;

                            ComPlusChannelCreatedTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationChannelCreated,
                                                             SR.TraceCodeComIntegrationChannelCreated, serviceEndpoint.Address.Uri, contractDescription.ContractType);

                            if (serviceChannel == null)
                            {
                                throw Fx.AssertAndThrow("serviceProxy MUST derive from RealProxy");
                            }
                        }
                        finally
                        {
                            if ((serviceChannel == null) && (serviceChannelFactory != null))
                            {
                                serviceChannelFactory.Close();
                            }
                        }
                    }
                }
            }
            return(serviceChannel);
        }
Beispiel #3
0
 RealProxy ICreateServiceChannel.CreateChannel()
 {
     if (this.serviceProxy == null)
     {
         lock (this)
         {
             if (this.serviceProxy == null)
             {
                 try
                 {
                     if (this.serviceChannelFactory == null)
                     {
                         this.FaultInserviceChannelFactory();
                     }
                     if (this.serviceChannelFactory == null)
                     {
                         throw Fx.AssertAndThrow("ServiceChannelFactory cannot be null at this point");
                     }
                     this.serviceChannelFactory.Open();
                     if (this.contractType == null)
                     {
                         throw Fx.AssertAndThrow("contractType cannot be null");
                     }
                     if (this.serviceEndpoint == null)
                     {
                         throw Fx.AssertAndThrow("serviceEndpoint cannot be null");
                     }
                     object obj2 = this.serviceChannelFactory.CreateChannel(this.contractType, new EndpointAddress(this.serviceEndpoint.Address.Uri, this.serviceEndpoint.Address.Identity, this.serviceEndpoint.Address.Headers), this.serviceEndpoint.Address.Uri);
                     ComPlusChannelCreatedTrace.Trace(TraceEventType.Verbose, 0x5001f, "TraceCodeComIntegrationChannelCreated", this.serviceEndpoint.Address.Uri, this.contractType);
                     RealProxy realProxy = RemotingServices.GetRealProxy(obj2);
                     Thread.MemoryBarrier();
                     this.serviceProxy = realProxy;
                     if (this.serviceProxy == null)
                     {
                         throw Fx.AssertAndThrow("serviceProxy MUST derive from RealProxy");
                     }
                 }
                 finally
                 {
                     if ((this.serviceProxy == null) && (this.serviceChannelFactory != null))
                     {
                         this.serviceChannelFactory.Close();
                     }
                 }
             }
         }
     }
     return(this.serviceProxy);
 }
 private ServiceChannel CreateChannel()
 {
     Thread.MemoryBarrier();
     if (this.serviceChannel == null)
     {
         lock (this)
         {
             Thread.MemoryBarrier();
             if (this.serviceChannel == null)
             {
                 try
                 {
                     if (this.serviceChannelFactory == null)
                     {
                         this.FaultInserviceChannelFactory();
                     }
                     if (this.serviceChannelFactory == null)
                     {
                         throw Fx.AssertAndThrow("ServiceChannelFactory cannot be null at this point");
                     }
                     this.serviceChannelFactory.Open();
                     if (this.serviceEndpoint == null)
                     {
                         throw Fx.AssertAndThrow("ServiceEndpoint cannot be null");
                     }
                     this.serviceChannel = this.serviceChannelFactory.CreateServiceChannel(new EndpointAddress(this.serviceEndpoint.Address.Uri, this.serviceEndpoint.Address.Identity, this.serviceEndpoint.Address.Headers), this.serviceEndpoint.Address.Uri);
                     ComPlusChannelCreatedTrace.Trace(TraceEventType.Verbose, 0x5001f, "TraceCodeComIntegrationChannelCreated", this.serviceEndpoint.Address.Uri, this.contractDescription.ContractType);
                     if (this.serviceChannel == null)
                     {
                         throw Fx.AssertAndThrow("serviceProxy MUST derive from RealProxy");
                     }
                 }
                 finally
                 {
                     if ((this.serviceChannel == null) && (this.serviceChannelFactory != null))
                     {
                         this.serviceChannelFactory.Close();
                     }
                 }
             }
         }
     }
     return(this.serviceChannel);
 }