NotFiniteNumberException.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Runtime.Serialization;
  5. namespace System
  6. {
  7. [Serializable]
  8. [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
  9. public class NotFiniteNumberException : ArithmeticException
  10. {
  11. private double _offendingNumber;
  12. public NotFiniteNumberException()
  13. : base(SR.Arg_NotFiniteNumberException)
  14. {
  15. _offendingNumber = 0;
  16. HResult = HResults.COR_E_NOTFINITENUMBER;
  17. }
  18. public NotFiniteNumberException(double offendingNumber)
  19. : base()
  20. {
  21. _offendingNumber = offendingNumber;
  22. HResult = HResults.COR_E_NOTFINITENUMBER;
  23. }
  24. public NotFiniteNumberException(string message)
  25. : base(message)
  26. {
  27. _offendingNumber = 0;
  28. HResult = HResults.COR_E_NOTFINITENUMBER;
  29. }
  30. public NotFiniteNumberException(string message, double offendingNumber)
  31. : base(message)
  32. {
  33. _offendingNumber = offendingNumber;
  34. HResult = HResults.COR_E_NOTFINITENUMBER;
  35. }
  36. public NotFiniteNumberException(string message, Exception innerException)
  37. : base(message, innerException)
  38. {
  39. HResult = HResults.COR_E_NOTFINITENUMBER;
  40. }
  41. public NotFiniteNumberException(string message, double offendingNumber, Exception innerException)
  42. : base(message, innerException)
  43. {
  44. _offendingNumber = offendingNumber;
  45. HResult = HResults.COR_E_NOTFINITENUMBER;
  46. }
  47. protected NotFiniteNumberException(SerializationInfo info, StreamingContext context) : base(info, context)
  48. {
  49. _offendingNumber = info.GetDouble("OffendingNumber"); // Do not rename (binary serialization)
  50. }
  51. public override void GetObjectData(SerializationInfo info, StreamingContext context)
  52. {
  53. base.GetObjectData(info, context);
  54. info.AddValue("OffendingNumber", _offendingNumber, typeof(double)); // Do not rename (binary serialization)
  55. }
  56. public double OffendingNumber
  57. {
  58. get { return _offendingNumber; }
  59. }
  60. }
  61. }