ConfigurationChannelFactory.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  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 ConfigurationChannelFactory<TChannel> : ChannelFactory<TChannel>
  10. {
  11. // TChannel provides ContractDescription, attr/config|Config object [TChannel,name] provides Binding, provide Address explicitly
  12. public ConfigurationChannelFactory(string endpointConfigurationName, Configuration configuration, EndpointAddress remoteAddress)
  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, typeof(TChannel).FullName), ActivityType.Construct);
  20. }
  21. if (endpointConfigurationName == null)
  22. {
  23. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointConfigurationName");
  24. }
  25. if (configuration == null)
  26. {
  27. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("configuration");
  28. }
  29. this.InitializeEndpoint(endpointConfigurationName, remoteAddress, configuration);
  30. }
  31. }
  32. }
  33. }