コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WcfLogReceiverClientFacade"/> class.
 /// </summary>
 /// <param name="useOneWay">Whether to use the one way or two way WCF client.</param>
 /// <param name="endpointConfigurationName">Name of the endpoint configuration.</param>
 public WcfLogReceiverClientFacade(bool useOneWay, string endpointConfigurationName)
 {
     m_useOneWay = useOneWay;
     if (useOneWay)
     {
         m_twoWayClient = null;
         m_oneWayClient = new WcfLogReceiverOneWayClient(endpointConfigurationName);
         HookOneWayEvents();
     }
     else
     {
         m_twoWayClient = new WcfLogReceiverClient(endpointConfigurationName);
         m_oneWayClient = null;
         HookTwoWayEvents();
     }
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WcfLogReceiverClientFacade"/> class.
 /// </summary>
 /// <param name="useOneWay">Whether to use the one way or two way WCF client.</param>
 /// <param name="binding">The binding.</param>
 /// <param name="remoteAddress">The remote address.</param>
 public WcfLogReceiverClientFacade(bool useOneWay, Binding binding, EndpointAddress remoteAddress)
 {
     m_useOneWay = useOneWay;
     if (useOneWay)
     {
         m_twoWayClient = null;
         m_oneWayClient = new WcfLogReceiverOneWayClient(binding, remoteAddress);
         HookOneWayEvents();
     }
     else
     {
         m_twoWayClient = new WcfLogReceiverClient(binding, remoteAddress);
         m_oneWayClient = null;
         HookTwoWayEvents();
     }
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WcfLogReceiverClientFacade"/> class.
 /// </summary>
 /// <param name="useOneWay">Whether to use the one way or two way WCF client.</param>
 public WcfLogReceiverClientFacade(bool useOneWay)
 {
     m_useOneWay = useOneWay;
     if (useOneWay)
     {
         m_twoWayClient = null;
         m_oneWayClient = new WcfLogReceiverOneWayClient();
         HookOneWayEvents();
     }
     else
     {
         m_twoWayClient = new WcfLogReceiverClient();
         m_oneWayClient = null;
         HookTwoWayEvents();
     }
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WcfLogReceiverClientFacade"/> class.
 /// </summary>
 /// <param name="useOneWay">Whether to use the one way or two way WCF client.</param>
 public WcfLogReceiverClientFacade(bool useOneWay)
 {
     m_useOneWay = useOneWay;
     if (useOneWay)
     {
         m_twoWayClient = null;
         m_oneWayClient = new WcfLogReceiverOneWayClient();
         HookOneWayEvents();
     }
     else
     {
         m_twoWayClient = new WcfLogReceiverClient();
         m_oneWayClient = null;
         HookTwoWayEvents();
     }
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WcfLogReceiverClientFacade"/> class.
 /// </summary>
 /// <param name="useOneWay">Whether to use the one way or two way WCF client.</param>
 /// <param name="endpointConfigurationName">Name of the endpoint configuration.</param>
 public WcfLogReceiverClientFacade(bool useOneWay, string endpointConfigurationName)
 {
     m_useOneWay = useOneWay;
     if (useOneWay)
     {
         m_twoWayClient = null;
         m_oneWayClient = new WcfLogReceiverOneWayClient(endpointConfigurationName);
         HookOneWayEvents();
     }
     else
     {
         m_twoWayClient = new WcfLogReceiverClient(endpointConfigurationName);
         m_oneWayClient = null;
         HookTwoWayEvents();
     }
 }
コード例 #6
0
        protected virtual WcfLogReceiverClient CreateWcfLogReceiverClient()
        {
            WcfLogReceiverClient client;

            if (string.IsNullOrEmpty(this.EndpointConfigurationName))
            {
                // endpoint not specified - use BasicHttpBinding
                Binding binding;

                if (this.UseBinaryEncoding)
                {
                    binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement());
                }
                else
                {
                    binding = new BasicHttpBinding();
                }

                client = new WcfLogReceiverClient(UseOneWayContract, binding, new EndpointAddress(this.EndpointAddress));
            }
            else
            {
                client = new WcfLogReceiverClient(UseOneWayContract, this.EndpointConfigurationName, new EndpointAddress(this.EndpointAddress));
            }

            client.ProcessLogMessagesCompleted += ClientOnProcessLogMessagesCompleted;

            return client;
        }
コード例 #7
0
        private void Send(NLogEvents events, IEnumerable<AsyncLogEventInfo> asyncContinuations)
        {
            if (!this.OnSend(events, asyncContinuations))
            {
                return;
            }

#if WCF_SUPPORTED
            WcfLogReceiverClient client;

            if (string.IsNullOrEmpty(this.EndpointConfigurationName))
            {
                // endpoint not specified - use BasicHttpBinding
                Binding binding;

#if !SILVERLIGHT2
                if (this.UseBinaryEncoding)
                {
                    binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement());
                }
                else
#endif
                {
                    binding = new BasicHttpBinding();
                 }

                client = new WcfLogReceiverClient(binding, new EndpointAddress(this.EndpointAddress));
            }
            else
            {
                client = new WcfLogReceiverClient(this.EndpointConfigurationName, new EndpointAddress(this.EndpointAddress));
            }

            client.ProcessLogMessagesCompleted += (sender, e) =>
                {
                    // report error to the callers
                    foreach (var ev in asyncContinuations)
                    {
                        ev.Continuation(e.Error);
                    }

                    // send any buffered events
                    this.SendBufferedEvents();
                };

            this.inCall = true;
#if SILVERLIGHT
            if (!Deployment.Current.Dispatcher.CheckAccess())
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => client.ProcessLogMessagesAsync(events));
            }
            else
            {
                client.ProcessLogMessagesAsync(events);
            }
#else
            client.ProcessLogMessagesAsync(events);
#endif
#else
            var client = new SoapLogReceiverClient(this.EndpointAddress);
            this.inCall = true;
            client.BeginProcessLogMessages(
                events,
                result =>
                    {
                        Exception exception = null;

                        try
                        {
                            client.EndProcessLogMessages(result);
                        }
                        catch (Exception ex)
                        {
                            if (ex.MustBeRethrown())
                            {
                                throw;
                            }

                            exception = ex;
                        }

                        // report error to the callers
                        foreach (var ev in asyncContinuations)
                        {
                            ev.Continuation(exception);
                        }

                        // send any buffered events
                        this.SendBufferedEvents();
                    },
                null);
#endif
        }
コード例 #8
0
        private void Send(NLogEvents events, IEnumerable<AsyncLogEventInfo> asyncContinuations)
        {
            if (!OnSend(events, asyncContinuations))
            {
                return;
            }

            WcfLogReceiverClient client;

            if (string.IsNullOrEmpty(EndpointConfigurationName))
            {
                // endpoint not specified - use BasicHttpBinding
                Binding binding;

                if (UseBinaryEncoding)
                {
                    binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement());
                }
                else
                {
                    binding = new BasicHttpBinding();
                }

                client = new WcfLogReceiverClient(binding, new EndpointAddress(EndpointAddress));
            }
            else
            {
                client = new WcfLogReceiverClient(EndpointConfigurationName, new EndpointAddress(EndpointAddress));
            }

            client.ProcessLogMessagesCompleted += (sender, e) =>
                {
                    // report error to the callers
                    foreach (var ev in asyncContinuations)
                    {
                        ev.Continuation(e.Error);
                    }

                    // send any buffered events
                    SendBufferedEvents();
                };

            inCall = true;
            client.ProcessLogMessagesAsync(events);
        }
コード例 #9
0
        private void Send(NLogEvents events, AsyncContinuation[] asyncContinuations)
        {
            #if WCF_SUPPORTED
            WcfLogReceiverClient client;

            if (string.IsNullOrEmpty(this.EndpointConfigurationName))
            {
                // endpoint not specified - use BasicHttpBinding
                var binding = new BasicHttpBinding();
                client = new WcfLogReceiverClient(binding, new EndpointAddress(this.EndpointAddress));
            }
            else
            {
                client = new WcfLogReceiverClient(this.EndpointConfigurationName, new EndpointAddress(this.EndpointAddress));
            }

            client.ProcessLogMessagesCompleted += (sender, e) =>
                {
                    // report error to the callers
                    foreach (var cont in asyncContinuations)
                    {
                        cont(e.Error);
                    }
                };

            client.ProcessLogMessagesAsync(events);
            #endif
        }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WcfLogReceiverClientFacade"/> class.
 /// </summary>
 /// <param name="useOneWay">Whether to use the one way or two way WCF client.</param>
 /// <param name="binding">The binding.</param>
 /// <param name="remoteAddress">The remote address.</param>
 public WcfLogReceiverClientFacade(bool useOneWay, Binding binding, EndpointAddress remoteAddress)
 {
     m_useOneWay = useOneWay;
     if (useOneWay)
     {
         m_twoWayClient = null;
         m_oneWayClient = new WcfLogReceiverOneWayClient(binding, remoteAddress);
         HookOneWayEvents();
     }
     else
     {
         m_twoWayClient = new WcfLogReceiverClient(binding, remoteAddress);
         m_oneWayClient = null;
         HookTwoWayEvents();
     }
 }