[threads] Don't ignore abort requests in abort protected blocks
[mono.git] / mcs / class / referencesource / System.Data / System / Data / CodeGen / StrongTypingException.cs
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
10 namespace System.Data {
11     using System;
12     using System.Collections;
13     using System.Data;
14     using System.Runtime.Serialization;
15
16     /// <devdoc>
17     ///    <para>DEV: The exception that is throwing from strong typed DataSet when user access to DBNull value.</para>
18     /// </devdoc>
19     [Serializable]
20     public class StrongTypingException : DataException {
21         protected StrongTypingException(SerializationInfo info, StreamingContext context)
22         : base(info, context) {
23         }
24         /// <devdoc>
25         ///    <para>[To be supplied.]</para>
26         /// </devdoc>
27         public StrongTypingException() : base() {
28             HResult = HResults.StrongTyping;
29         }
30
31         public StrongTypingException(string message)  : base(message) {
32             HResult = HResults.StrongTyping;
33         }
34         
35         /// <devdoc>
36         ///    <para>[To be supplied.]</para>
37         /// </devdoc>
38         public StrongTypingException(string s, Exception innerException) : base(s, innerException) {
39             HResult = HResults.StrongTyping;
40         }
41     }
42
43
44     /// <devdoc>
45     ///    <para>DEV: The exception that is throwing in generating strong typed DataSet when name conflict happens.</para>
46     /// </devdoc>
47     [Serializable]
48     public class TypedDataSetGeneratorException : DataException {
49         private ArrayList errorList;
50         private string KEY_ARRAYCOUNT = "KEY_ARRAYCOUNT";
51         private string KEY_ARRAYVALUES = "KEY_ARRAYVALUES";
52
53         protected TypedDataSetGeneratorException(SerializationInfo info, StreamingContext context)
54         : base(info, context) {
55             int count = (int) info.GetValue(KEY_ARRAYCOUNT, typeof(System.Int32));
56             if (count > 0) {
57                 errorList = new ArrayList();
58                 for (int i = 0; i < count; i++) {
59                     errorList.Add(info.GetValue(KEY_ARRAYVALUES + i, typeof(System.String)));
60                 }
61             }
62             else
63                 errorList = null;
64         }
65
66         /// <devdoc>
67         ///    <para>[To be supplied.]</para>
68         /// </devdoc>
69         public TypedDataSetGeneratorException() : base() {
70             errorList = null;
71             HResult = HResults.StrongTyping;
72         }
73
74         public TypedDataSetGeneratorException(string message)  : base(message) {
75             HResult = HResults.StrongTyping;
76         }
77
78         public TypedDataSetGeneratorException(string message, Exception innerException)  : base(message, innerException) {
79             HResult = HResults.StrongTyping;
80         }
81
82         /// <devdoc>
83         ///    <para>[To be supplied.]</para>
84         /// </devdoc>
85         public TypedDataSetGeneratorException(ArrayList list) : this() {
86             errorList = list;
87             HResult = HResults.StrongTyping;
88         }
89
90         /// <devdoc>
91         ///    <para>[To be supplied.]</para>
92         /// </devdoc>
93         public ArrayList ErrorList {
94             get {
95                 return errorList;
96             }
97         }
98         
99         [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags=System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)]
100         public override void GetObjectData(SerializationInfo info, StreamingContext context)
101         {
102             base.GetObjectData(info, context);
103
104             if (errorList != null) {
105                 info.AddValue(KEY_ARRAYCOUNT, errorList.Count);
106                 for (int i = 0; i < errorList.Count; i++) {
107                     info.AddValue(KEY_ARRAYVALUES + i, errorList[i].ToString());
108                 }
109             }
110             else {
111                 info.AddValue(KEY_ARRAYCOUNT, 0);
112             }
113         }
114     }
115 }