The Labs \ Source Viewer \ SSCLI \ System.Configuration \ ConfigurationValidatorAttribute

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ConfigurationValidatorAttribute.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. using System;
  16. using System.Configuration.Internal;
  17. using System.Collections;
  18. using System.Collections.Specialized;
  19. using System.Collections.Generic;
  20. using System.IO;
  21. using System.Reflection;
  22. using System.Security.Permissions;
  23. using System.Xml;
  24. using System.Globalization;
  25. using System.ComponentModel;
  26. using System.Security;
  27. using System.Text;
  28. namespace System.Configuration
  29. {
  30.    
  31.     [AttributeUsage(AttributeTargets.Property)]
  32.     public class ConfigurationValidatorAttribute : Attribute
  33.     {
  34.         Type _validator;
  35.        
  36.         protected ConfigurationValidatorAttribute()
  37.         {
  38.         }
  39.         public ConfigurationValidatorAttribute(Type validator)
  40.         {
  41.             if (validator == null) {
  42.                 throw new ArgumentNullException("validator");
  43.             }
  44.            
  45.             if (!typeof(ConfigurationValidatorBase).IsAssignableFrom(validator)) {
  46.                 throw new ArgumentException(SR.GetString(SR.Validator_Attribute_param_not_validator, "ConfigurationValidatorBase"));
  47.             }
  48.            
  49.             _validator = validator;
  50.         }
  51.         public virtual ConfigurationValidatorBase ValidatorInstance {
  52.             get { return (ConfigurationValidatorBase)TypeUtil.CreateInstanceWithReflectionPermission(_validator); }
  53.         }
  54.        
  55.         public Type ValidatorType {
  56.             get { return _validator; }
  57.         }
  58.     }
  59. }

Developer Fusion