InvalidEnumArgumentException.cs 840 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // System.ComponentModel.InvalidEnumArgumentException.cs
  3. //
  4. // Author:
  5. // Duncan Mak ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc. http://www.ximian.com
  8. //
  9. using System;
  10. namespace System.ComponentModel
  11. {
  12. [Serializable]
  13. public class InvalidEnumArgumentException : ArgumentException
  14. {
  15. string msg = String.Empty;
  16. public InvalidEnumArgumentException () : base ()
  17. {
  18. }
  19. public InvalidEnumArgumentException (string message)
  20. {
  21. msg = message;
  22. }
  23. public InvalidEnumArgumentException (string argumentName, int invalidValue, Type enumClass)
  24. {
  25. msg = argumentName + " is invalid because this value, " + invalidValue + " is not of type " + enumClass.Name;
  26. }
  27. public override string Message {
  28. get {
  29. if (ParamName == String.Empty)
  30. return msg;
  31. else
  32. return ParamName + ": " + msg;
  33. }
  34. }
  35. }
  36. }