NamedServiceModelExtensionCollectionElement.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System;
  7. using System.Configuration;
  8. public abstract class NamedServiceModelExtensionCollectionElement<TServiceModelExtensionElement> : ServiceModelExtensionCollectionElement<TServiceModelExtensionElement>
  9. where TServiceModelExtensionElement : ServiceModelExtensionElement
  10. {
  11. ConfigurationPropertyCollection properties = null;
  12. internal NamedServiceModelExtensionCollectionElement(string extensionCollectionName, string name)
  13. : base(extensionCollectionName)
  14. {
  15. if (!String.IsNullOrEmpty(name))
  16. {
  17. this.Name = name;
  18. }
  19. else
  20. {
  21. this.Name = String.Empty;
  22. }
  23. }
  24. [ConfigurationProperty(ConfigurationStrings.Name, Options = ConfigurationPropertyOptions.IsKey)]
  25. [StringValidator(MinLength = 0)]
  26. public string Name
  27. {
  28. get { return (string)base[ConfigurationStrings.Name]; }
  29. set
  30. {
  31. if (String.IsNullOrEmpty(value))
  32. {
  33. value = String.Empty;
  34. }
  35. base[ConfigurationStrings.Name] = value;
  36. this.SetIsModified();
  37. }
  38. }
  39. protected override ConfigurationPropertyCollection Properties
  40. {
  41. get
  42. {
  43. if (this.properties == null)
  44. {
  45. this.properties = base.Properties;
  46. this.properties.Add(new ConfigurationProperty(ConfigurationStrings.Name, typeof(System.String), null, null, new StringValidator(0, 2147483647, null), System.Configuration.ConfigurationPropertyOptions.IsKey));
  47. }
  48. return this.properties;
  49. }
  50. }
  51. }
  52. }