//
        // Without cancellation token
        //
        public async Task SetSocketOptionAsync(SocketOption option, ulong value)
        {
            var cts = new CancellationTokenSource(SendTimeout);

            try {
                await SetSocketOptionAsync(option, value, cts.Token).ConfigureAwait(false);
            }
            catch (OperationCanceledException) when(cts.IsCancellationRequested)
            {
                throw new TimeoutException(
                          $"Timeout on send socket option after {SendTimeout.ToString()}.");
            }
        }
Example #2
0
        //
        // Without cancellation token
        //
        public async Task CloseAsync()
        {
            var cts = new CancellationTokenSource(SendTimeout);

            try {
                await CloseAsync(cts.Token).ConfigureAwait(false);
            }
            catch (OperationCanceledException) when(cts.IsCancellationRequested)
            {
                throw new TimeoutException(
                          $"Timeout on close socket after {SendTimeout.ToString()}.");
            }
        }
Example #3
0
        public void Save([NotNull] XmlTextWriter output)
        {
            Assert.ArgumentNotNull(output, nameof(output));

            var blowFish          = new BlowFish(BlowFish.CipherKey);
            var encryptedPassword = blowFish.Encrypt_ECB(Password);

            output.WriteStartElement(@"binding");

            output.WriteAttributeString(@"hostName", HostName);
            output.WriteAttributeString(@"useWindowsAuth", UseWindowsAuth ? @"true" : @"false");
            output.WriteAttributeString(@"userName", UserName);
            output.WriteAttributeString(@"password", encryptedPassword);
            output.WriteAttributeString(@"dataService", DataServiceName);
            output.WriteAttributeString(@"webRootPath", WebRootPath);
            output.WriteAttributeString(@"description", Description);
            output.WriteAttributeString(@"isRemoteSitecore", IsRemoteSitecore ? @"true" : @"false");
            output.WriteAttributeString(@"automaticallyUpdate", AutomaticallyUpdate ? @"true" : @"false");
            output.WriteAttributeString(@"isHidden", IsHidden ? @"true" : @"false");

            output.WriteAttributeString(@"hostNameComparisonMode", HostNameComparisonMode.ToString());
            output.WriteAttributeString(@"receiveTimeout", ReceiveTimeout.ToString());
            output.WriteAttributeString(@"sendTimeout", SendTimeout.ToString());
            output.WriteAttributeString(@"openTimeout", OpenTimeout.ToString());
            output.WriteAttributeString(@"closeTimeout", CloseTimeout.ToString());
            output.WriteAttributeString(@"maxReceivedMessageSize", MaxReceivedMessageSize.ToString());
            output.WriteAttributeString(@"maxBufferSize", MaxBufferSize.ToString());
            output.WriteAttributeString(@"maxBufferPoolSize", MaxBufferPoolSize.ToString());
            output.WriteAttributeString(@"maxStringContentLength", MaxStringContentLength.ToString());
            output.WriteAttributeString(@"transferMode", TransferMode.ToString());
            output.WriteAttributeString(@"messageEncoding", MessageEncoding.ToString());
            output.WriteAttributeString(@"textEncoding", TextEncoding.WebName);
            output.WriteAttributeString(@"bypassProxyOnLocal", BypassProxyOnLocal ? @"true" : @"false");
            output.WriteAttributeString(@"useDefaultWebProxy", UseDefaultWebProxy ? @"true" : @"false");

            if (ProxyAddress != null)
            {
                output.WriteAttributeString(@"proxyAddress", ProxyAddress.ToString());
            }
            else
            {
                output.WriteAttributeString(@"proxyAddress", string.Empty);
            }

            output.WriteEndElement();
        }
        //
        // Without cancellation token
        //
        public async Task CloseAsync()
        {
            if (_cleanedUp)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }
            if (!Connected)
            {
                return;
            }

            var cts = new CancellationTokenSource(SendTimeout);

            try {
                await CloseAsync(cts.Token).ConfigureAwait(false);
            }
            catch (OperationCanceledException) when(cts.IsCancellationRequested)
            {
                throw new TimeoutException(
                          $"Timeout on close socket after {SendTimeout.ToString()}.");
            }
        }