Advertisement
Guest User

Untitled

a guest
Jan 14th, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. public partial class MedinectWebServiceExt : MedinectWebService.ServiceSoapClient, IDisposable
  2. {
  3. private bool isDisposed = false;
  4.  
  5. ~MedinectWebServiceExt() => Dispose(false);
  6.  
  7. public string Url
  8. {
  9. get { return base.Endpoint.Address.Uri.ToString(); }
  10. set { base.Endpoint.Address = new EndpointAddress(value); }
  11. }
  12.  
  13. public double Timeout
  14. {
  15. get { return base.InnerChannel.OperationTimeout.TotalMilliseconds; }
  16. set { base.InnerChannel.OperationTimeout = TimeSpan.FromMilliseconds(value); }
  17. }
  18.  
  19. public MedinectWebServiceExt(string url) : base(new WSHttpBinding { OpenTimeout = new TimeSpan(0, 10, 0), CloseTimeout = new TimeSpan(0, 10, 0), SendTimeout = new TimeSpan(0, 10, 0), ReceiveTimeout = new TimeSpan(0, 10, 0) }, new EndpointAddress(url))
  20. {
  21. base.ClientCredentials.ServiceCertificate.SslCertificateAuthentication =
  22. new X509ServiceCertificateAuthentication()
  23. {
  24. CertificateValidationMode = X509CertificateValidationMode.None,
  25. RevocationMode = X509RevocationMode.NoCheck
  26. };
  27. }
  28.  
  29. public MedinectWebServiceExt(EndpointConfiguration endpointConfiguration = EndpointConfiguration.ServiceSoap) : base(endpointConfiguration)
  30. {
  31. base.ClientCredentials.ServiceCertificate.SslCertificateAuthentication =
  32. new X509ServiceCertificateAuthentication()
  33. {
  34. CertificateValidationMode = X509CertificateValidationMode.None,
  35. RevocationMode = X509RevocationMode.NoCheck
  36. };
  37. }
  38.  
  39. protected virtual void Dispose(bool disposing)
  40. {
  41. if (isDisposed)
  42. return;
  43.  
  44. try
  45. {
  46. if (base.State == CommunicationState.Faulted)
  47. base.Abort();
  48. else
  49. {
  50. try
  51. {
  52. base.Close();
  53. }
  54. catch (Exception closeException)
  55. {
  56. try
  57. {
  58. base.Abort();
  59. }
  60. catch (Exception abortException)
  61. {
  62. throw new AggregateException(closeException, abortException);
  63. }
  64. throw;
  65. }
  66. }
  67. }
  68. finally
  69. {
  70. isDisposed = true;
  71. }
  72. }
  73.  
  74. public void Dispose()
  75. {
  76. // Dispose of unmanaged resources.
  77. Dispose(true);
  78. // Suppress finalization.
  79. GC.SuppressFinalize(this);
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement