BaseCollection.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //------------------------------------------------------------------------------
  2. // <copyright file="BaseCollection.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.ComponentModel;
  13. using System.Globalization;
  14. /// <devdoc>
  15. /// <para>Provides the base functionality for creating collections.</para>
  16. /// </devdoc>
  17. public class InternalDataCollectionBase : ICollection {
  18. internal static CollectionChangeEventArgs RefreshEventArgs = new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null);
  19. //==================================================
  20. // the ICollection methods
  21. //==================================================
  22. /// <devdoc>
  23. /// <para>Gets the total number of elements in a collection.</para>
  24. /// </devdoc>
  25. [
  26. Browsable(false)
  27. ]
  28. public virtual int Count {
  29. get {
  30. return List.Count;
  31. }
  32. }
  33. public virtual void CopyTo(Array ar, int index) {
  34. List.CopyTo(ar, index);
  35. }
  36. public virtual IEnumerator GetEnumerator() {
  37. return List.GetEnumerator();
  38. }
  39. [
  40. Browsable(false)
  41. ]
  42. public bool IsReadOnly {
  43. get {
  44. return false;
  45. }
  46. }
  47. [Browsable(false)]
  48. public bool IsSynchronized {
  49. get {
  50. // so the user will know that it has to lock this object
  51. return false;
  52. }
  53. }
  54. // Return value:
  55. // > 0 (1) : CaseSensitve equal
  56. // < 0 (-1) : Case-Insensitive Equal
  57. // = 0 : Not Equal
  58. internal int NamesEqual(string s1, string s2, bool fCaseSensitive, CultureInfo locale) {
  59. if (fCaseSensitive) {
  60. if (String.Compare(s1, s2, false, locale) == 0)
  61. return 1;
  62. else
  63. return 0;
  64. }
  65. // Case, kana and width -Insensitive compare
  66. if (locale.CompareInfo.Compare(s1, s2,
  67. CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth) == 0) {
  68. if (String.Compare(s1, s2, false, locale) == 0)
  69. return 1;
  70. else
  71. return -1;
  72. }
  73. return 0;
  74. }
  75. [Browsable(false)]
  76. public object SyncRoot {
  77. get {
  78. return this;
  79. }
  80. }
  81. protected virtual ArrayList List {
  82. get {
  83. return null;
  84. }
  85. }
  86. }
  87. }