ServiceElement.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //------------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------------------------
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System.Configuration;
  7. using System.Runtime;
  8. using System.Security;
  9. public sealed partial class ServiceElement : ConfigurationElement, IConfigurationContextProviderInternal
  10. {
  11. [Fx.Tag.SecurityNote(Critical = "Stores information used in a security decision.")]
  12. [SecurityCritical]
  13. EvaluationContextHelper contextHelper;
  14. public ServiceElement() : base() { }
  15. public ServiceElement(string serviceName)
  16. : this()
  17. {
  18. this.Name = serviceName;
  19. }
  20. [ConfigurationProperty(ConfigurationStrings.BehaviorConfiguration, DefaultValue = "")]
  21. [StringValidator(MinLength = 0)]
  22. public string BehaviorConfiguration
  23. {
  24. get { return (string)base[ConfigurationStrings.BehaviorConfiguration]; }
  25. set
  26. {
  27. if (String.IsNullOrEmpty(value))
  28. {
  29. value = String.Empty;
  30. }
  31. base[ConfigurationStrings.BehaviorConfiguration] = value;
  32. }
  33. }
  34. [ConfigurationProperty(ConfigurationStrings.DefaultCollectionName, Options = ConfigurationPropertyOptions.IsDefaultCollection)]
  35. public ServiceEndpointElementCollection Endpoints
  36. {
  37. get { return (ServiceEndpointElementCollection)base[ConfigurationStrings.DefaultCollectionName]; }
  38. }
  39. [ConfigurationProperty(ConfigurationStrings.Host, Options = ConfigurationPropertyOptions.None)]
  40. public HostElement Host
  41. {
  42. get { return (HostElement)base[ConfigurationStrings.Host]; }
  43. }
  44. [ConfigurationProperty(ConfigurationStrings.Name, Options = ConfigurationPropertyOptions.IsKey | ConfigurationPropertyOptions.IsRequired)]
  45. [StringValidator(MinLength = 1)]
  46. public string Name
  47. {
  48. get { return (string)base[ConfigurationStrings.Name]; }
  49. set
  50. {
  51. if (String.IsNullOrEmpty(value))
  52. {
  53. value = String.Empty;
  54. }
  55. base[ConfigurationStrings.Name] = value;
  56. }
  57. }
  58. [Fx.Tag.SecurityNote(Critical = "Accesses critical field contextHelper.")]
  59. [SecurityCritical]
  60. protected override void Reset(ConfigurationElement parentElement)
  61. {
  62. this.contextHelper.OnReset(parentElement);
  63. base.Reset(parentElement);
  64. }
  65. ContextInformation IConfigurationContextProviderInternal.GetEvaluationContext()
  66. {
  67. return this.EvaluationContext;
  68. }
  69. [Fx.Tag.SecurityNote(Critical = "Accesses critical field contextHelper.",
  70. Miscellaneous = "RequiresReview -- the return value will be used for a security decision -- see comment in interface definition")]
  71. [SecurityCritical]
  72. ContextInformation IConfigurationContextProviderInternal.GetOriginalEvaluationContext()
  73. {
  74. return this.contextHelper.GetOriginalContext(this);
  75. }
  76. }
  77. }