ConfigurationDuplexChannelFactory.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System.Collections.Generic;
  7. using System.Configuration;
  8. using System.ServiceModel.Diagnostics;
  9. public sealed class ConfigurationDuplexChannelFactory<TChannel> : DuplexChannelFactory<TChannel>
  10. {
  11. // TChannel provides ContractDescription, attr/config|Config object [TChannel,name] provides Binding, provide Address explicitly
  12. public ConfigurationDuplexChannelFactory(object callbackObject, string endpointConfigurationName, EndpointAddress remoteAddress, Configuration configuration)
  13. : base(typeof(TChannel))
  14. {
  15. using (ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.CreateBoundedActivity() : null)
  16. {
  17. if (DiagnosticUtility.ShouldUseActivity)
  18. {
  19. ServiceModelActivity.Start(activity, SR.GetString(SR.ActivityConstructChannelFactory, TraceUtility.CreateSourceString(this)), ActivityType.Construct);
  20. }
  21. if (callbackObject == null)
  22. {
  23. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("callbackObject");
  24. }
  25. if (endpointConfigurationName == null)
  26. {
  27. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointConfigurationName");
  28. }
  29. if (configuration == null)
  30. {
  31. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("configuration");
  32. }
  33. this.CheckAndAssignCallbackInstance(callbackObject);
  34. this.InitializeEndpoint(endpointConfigurationName, remoteAddress, configuration);
  35. }
  36. }
  37. }
  38. }