StrongTypingException.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //------------------------------------------------------------------------------
  2. // <copyright file="StrongTypingException.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">[....]</owner>
  6. // <owner current="true" primary="false">[....]</owner>
  7. // <owner current="false" primary="false">[....]</owner>
  8. //------------------------------------------------------------------------------
  9. namespace System.Data {
  10. using System;
  11. using System.Collections;
  12. using System.Data;
  13. using System.Runtime.Serialization;
  14. /// <devdoc>
  15. /// <para>DEV: The exception that is throwing from strong typed DataSet when user access to DBNull value.</para>
  16. /// </devdoc>
  17. [Serializable]
  18. public class StrongTypingException : DataException {
  19. protected StrongTypingException(SerializationInfo info, StreamingContext context)
  20. : base(info, context) {
  21. }
  22. /// <devdoc>
  23. /// <para>[To be supplied.]</para>
  24. /// </devdoc>
  25. public StrongTypingException() : base() {
  26. HResult = HResults.StrongTyping;
  27. }
  28. public StrongTypingException(string message) : base(message) {
  29. HResult = HResults.StrongTyping;
  30. }
  31. /// <devdoc>
  32. /// <para>[To be supplied.]</para>
  33. /// </devdoc>
  34. public StrongTypingException(string s, Exception innerException) : base(s, innerException) {
  35. HResult = HResults.StrongTyping;
  36. }
  37. }
  38. /// <devdoc>
  39. /// <para>DEV: The exception that is throwing in generating strong typed DataSet when name conflict happens.</para>
  40. /// </devdoc>
  41. [Serializable]
  42. public class TypedDataSetGeneratorException : DataException {
  43. private ArrayList errorList;
  44. private string KEY_ARRAYCOUNT = "KEY_ARRAYCOUNT";
  45. private string KEY_ARRAYVALUES = "KEY_ARRAYVALUES";
  46. protected TypedDataSetGeneratorException(SerializationInfo info, StreamingContext context)
  47. : base(info, context) {
  48. int count = (int) info.GetValue(KEY_ARRAYCOUNT, typeof(System.Int32));
  49. if (count > 0) {
  50. errorList = new ArrayList();
  51. for (int i = 0; i < count; i++) {
  52. errorList.Add(info.GetValue(KEY_ARRAYVALUES + i, typeof(System.String)));
  53. }
  54. }
  55. else
  56. errorList = null;
  57. }
  58. /// <devdoc>
  59. /// <para>[To be supplied.]</para>
  60. /// </devdoc>
  61. public TypedDataSetGeneratorException() : base() {
  62. errorList = null;
  63. HResult = HResults.StrongTyping;
  64. }
  65. public TypedDataSetGeneratorException(string message) : base(message) {
  66. HResult = HResults.StrongTyping;
  67. }
  68. public TypedDataSetGeneratorException(string message, Exception innerException) : base(message, innerException) {
  69. HResult = HResults.StrongTyping;
  70. }
  71. /// <devdoc>
  72. /// <para>[To be supplied.]</para>
  73. /// </devdoc>
  74. public TypedDataSetGeneratorException(ArrayList list) : this() {
  75. errorList = list;
  76. HResult = HResults.StrongTyping;
  77. }
  78. /// <devdoc>
  79. /// <para>[To be supplied.]</para>
  80. /// </devdoc>
  81. public ArrayList ErrorList {
  82. get {
  83. return errorList;
  84. }
  85. }
  86. [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags=System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)]
  87. public override void GetObjectData(SerializationInfo info, StreamingContext context)
  88. {
  89. base.GetObjectData(info, context);
  90. if (errorList != null) {
  91. info.AddValue(KEY_ARRAYCOUNT, errorList.Count);
  92. for (int i = 0; i < errorList.Count; i++) {
  93. info.AddValue(KEY_ARRAYVALUES + i, errorList[i].ToString());
  94. }
  95. }
  96. else {
  97. info.AddValue(KEY_ARRAYCOUNT, 0);
  98. }
  99. }
  100. }
  101. }