HttpMessageHandlerFactoryValidator.cs 1.0 KB

1234567891011121314151617181920212223242526
  1. // <copyright>
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. // </copyright>
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System;
  7. using System.Configuration;
  8. class HttpMessageHandlerFactoryValidator : ConfigurationValidatorBase
  9. {
  10. public override bool CanValidate(Type type)
  11. {
  12. return type == typeof(HttpMessageHandlerFactoryElement);
  13. }
  14. public override void Validate(object value)
  15. {
  16. HttpMessageHandlerFactoryElement configElement = (HttpMessageHandlerFactoryElement)value;
  17. if (!string.IsNullOrWhiteSpace(configElement.Type) && configElement.Handlers != null && configElement.Handlers.Count > 0)
  18. {
  19. throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR.GetString(SR.HttpMessageHandlerFactoryConfigInvalid_WithBothTypeAndHandlerList, ConfigurationStrings.MessageHandlerFactory, ConfigurationStrings.Type, ConfigurationStrings.Handlers)));
  20. }
  21. }
  22. }
  23. }