ServiceEndpointElementCollection.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //------------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------------------------
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System;
  7. using System.ServiceModel.Channels;
  8. using System.ServiceModel.Description;
  9. using System.Collections;
  10. using System.Configuration;
  11. using System.Globalization;
  12. [ConfigurationCollection(typeof(ServiceEndpointElement), AddItemName = ConfigurationStrings.Endpoint)]
  13. public sealed class ServiceEndpointElementCollection : ServiceModelEnhancedConfigurationElementCollection<ServiceEndpointElement>
  14. {
  15. public ServiceEndpointElementCollection()
  16. : base(ConfigurationStrings.Endpoint)
  17. { }
  18. protected override bool ThrowOnDuplicate
  19. {
  20. get { return false; }
  21. }
  22. protected override Object GetElementKey(ConfigurationElement element)
  23. {
  24. if (element == null)
  25. {
  26. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
  27. }
  28. ServiceEndpointElement configElementKey = (ServiceEndpointElement)element;
  29. // We need to provide something sufficiently unique for the underlying system.
  30. // Conceptually, this is an ever-expanding collection.
  31. // There is no logical object key for this collection.
  32. return string.Format(CultureInfo.InvariantCulture,
  33. "address:{0};bindingConfiguration{1};bindingName:{2};bindingNamespace:{3};bindingSectionName:{4};contractType:{5};kind:{6};endpointConfiguration:{7};",
  34. (configElementKey.Address == null) ? null : configElementKey.Address.ToString().ToUpperInvariant(),
  35. configElementKey.BindingConfiguration,
  36. configElementKey.BindingName,
  37. configElementKey.BindingNamespace,
  38. configElementKey.Binding,
  39. configElementKey.Contract,
  40. configElementKey.Kind,
  41. configElementKey.EndpointConfiguration);
  42. }
  43. }
  44. }