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