ChannelOptions.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.ComIntegration
  5. {
  6. using System;
  7. using System.Runtime.InteropServices;
  8. using System.Collections.Generic;
  9. using System.ServiceModel;
  10. using System.ServiceModel.Channels;
  11. internal class ChannelOptions : IChannelOptions, IDisposable
  12. {
  13. protected IProvideChannelBuilderSettings channelBuilderSettings;
  14. internal ChannelOptions(IProvideChannelBuilderSettings channelBuilderSettings)
  15. {
  16. this.channelBuilderSettings = channelBuilderSettings;
  17. }
  18. internal static ComProxy Create(IntPtr outer, IProvideChannelBuilderSettings channelBuilderSettings)
  19. {
  20. if (channelBuilderSettings == null)
  21. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotCreateChannelOption)));
  22. ChannelOptions channelOptions = null;
  23. ComProxy proxy = null;
  24. try
  25. {
  26. channelOptions = new ChannelOptions(channelBuilderSettings);
  27. proxy = ComProxy.Create(outer, channelOptions, channelOptions);
  28. return proxy;
  29. }
  30. finally
  31. {
  32. if (proxy == null)
  33. {
  34. if (channelOptions != null)
  35. ((IDisposable)channelOptions).Dispose();
  36. }
  37. }
  38. }
  39. void IDisposable.Dispose()
  40. {
  41. }
  42. }
  43. }