NotFiniteNumberException.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 readonly 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. {
  20. _offendingNumber = offendingNumber;
  21. HResult = HResults.COR_E_NOTFINITENUMBER;
  22. }
  23. public NotFiniteNumberException(string? message)
  24. : base(message)
  25. {
  26. _offendingNumber = 0;
  27. HResult = HResults.COR_E_NOTFINITENUMBER;
  28. }
  29. public NotFiniteNumberException(string? message, double offendingNumber)
  30. : base(message)
  31. {
  32. _offendingNumber = offendingNumber;
  33. HResult = HResults.COR_E_NOTFINITENUMBER;
  34. }
  35. public NotFiniteNumberException(string? message, Exception? innerException)
  36. : base(message, innerException)
  37. {
  38. HResult = HResults.COR_E_NOTFINITENUMBER;
  39. }
  40. public NotFiniteNumberException(string? message, double offendingNumber, Exception? innerException)
  41. : base(message, innerException)
  42. {
  43. _offendingNumber = offendingNumber;
  44. HResult = HResults.COR_E_NOTFINITENUMBER;
  45. }
  46. protected NotFiniteNumberException(SerializationInfo info, StreamingContext context) : base(info, context)
  47. {
  48. _offendingNumber = info.GetDouble("OffendingNumber"); // Do not rename (binary serialization)
  49. }
  50. public override void GetObjectData(SerializationInfo info, StreamingContext context)
  51. {
  52. base.GetObjectData(info, context);
  53. info.AddValue("OffendingNumber", _offendingNumber, typeof(double)); // Do not rename (binary serialization)
  54. }
  55. public double OffendingNumber => _offendingNumber;
  56. }
  57. }