Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data / System / Data / DBConcurrencyException.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="DBConcurrencyException.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 //------------------------------------------------------------------------------
8
9 namespace System.Data {
10
11     using System;
12     using System.Globalization;
13     using System.Runtime.Serialization;
14
15     [Serializable]
16     public sealed class DBConcurrencyException  : SystemException {
17         private DataRow[] _dataRows;
18
19         public DBConcurrencyException() : this(Res.GetString(Res.ADP_DBConcurrencyExceptionMessage), null) { // MDAC 84941
20         }
21
22         public DBConcurrencyException(string message) : this(message, null) {
23         }
24
25         public DBConcurrencyException(string message, Exception inner) : base(message, inner) {
26             HResult = HResults.DBConcurrency; // MDAC 84941
27         }
28
29         public DBConcurrencyException(string message, Exception inner, DataRow[] dataRows) : base(message, inner) {
30             HResult = HResults.DBConcurrency; // MDAC 84941
31             _dataRows = dataRows;
32         }
33
34         // runtime will call even if private...
35         private DBConcurrencyException(SerializationInfo si, StreamingContext sc) : base(si, sc) {
36             // dataRow = (DataRow) si.GetValue("dataRow", typeof(DataRow)); - do not do this till v.next with serialization support for DataRow.  MDAC 72136
37         }
38
39         [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Flags=System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter)]
40         override public void GetObjectData(SerializationInfo si, StreamingContext context) { // MDAC 72003
41             if (null == si) {
42                 throw new ArgumentNullException("si");
43             }
44             // si.AddValue("dataRow", dataRow, typeof(DataRow)); - do not do this till v.next with serialization support for DataRow.    MDAC 72136
45             base.GetObjectData(si, context);
46         }
47
48         public DataRow Row { // MDAC 55735
49             get {
50                 DataRow[] rows = _dataRows;
51                 return (((null != rows) && (0 < rows.Length)) ? rows[0] : null);
52             }
53             set {
54                 _dataRows = new DataRow[1] { value };
55             }
56         }
57         
58         public int RowCount {
59             get {
60                 DataRow[] dataRows = _dataRows;
61                 return ((null != dataRows) ? dataRows.Length : 0);
62             }
63         }
64         
65         public void CopyToRows(DataRow[] array) {
66             CopyToRows(array, 0);
67         }
68         
69         public void CopyToRows(DataRow[] array, int arrayIndex) {
70             DataRow[] dataRows = _dataRows;
71             if (null != dataRows) {
72                 dataRows.CopyTo(array, arrayIndex);
73             }
74         }
75     }
76 }