DBConcurrencyException.cs 3.0 KB

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