EventLogPermissionEntryCollection.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // System.Diagnostics.EventLogPermissionEntryCollection.cs
  3. //
  4. // Authors:
  5. // Jonathan Pryor ([email protected])
  6. // Andreas Nahr ([email protected])
  7. // Sebastien Pouliot <[email protected]>
  8. //
  9. // (C) 2002 Jonathan Pryor
  10. // (C) 2003 Andreas Nahr
  11. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. using System.Collections;
  33. using System.Security.Permissions;
  34. namespace System.Diagnostics {
  35. [Serializable]
  36. public class EventLogPermissionEntryCollection : CollectionBase {
  37. private EventLogPermission owner;
  38. internal EventLogPermissionEntryCollection (EventLogPermission owner)
  39. {
  40. this.owner = owner;
  41. ResourcePermissionBaseEntry[] entries = owner.GetEntries ();
  42. if (entries.Length > 0) {
  43. foreach (ResourcePermissionBaseEntry entry in entries) {
  44. EventLogPermissionAccess elpa = (EventLogPermissionAccess) entry.PermissionAccess;
  45. EventLogPermissionEntry elpe = new EventLogPermissionEntry (elpa, entry.PermissionAccessPath [0]);
  46. // we don't want to add them (again) to the base class
  47. InnerList.Add (elpe);
  48. }
  49. }
  50. }
  51. public EventLogPermissionEntry this [int index] {
  52. get { return ((EventLogPermissionEntry) List[index]); }
  53. set { List[index] = value; }
  54. }
  55. public int Add(EventLogPermissionEntry value)
  56. {
  57. return List.Add (value);
  58. }
  59. public void AddRange(EventLogPermissionEntry[] value)
  60. {
  61. foreach (EventLogPermissionEntry entry in value)
  62. List.Add (entry);
  63. }
  64. public void AddRange(EventLogPermissionEntryCollection value)
  65. {
  66. foreach (EventLogPermissionEntry entry in value)
  67. List.Add (entry);
  68. }
  69. public bool Contains (EventLogPermissionEntry value)
  70. {
  71. return List.Contains (value);
  72. }
  73. public void CopyTo (EventLogPermissionEntry[] array, int index)
  74. {
  75. List.CopyTo (array, index);
  76. }
  77. public int IndexOf (EventLogPermissionEntry value)
  78. {
  79. return List.IndexOf (value);
  80. }
  81. public void Insert (int index, EventLogPermissionEntry value)
  82. {
  83. List.Insert (index, value);
  84. }
  85. protected override void OnClear ()
  86. {
  87. owner.ClearEntries ();
  88. }
  89. protected override void OnInsert (int index, object value)
  90. {
  91. owner.Add (value);
  92. }
  93. protected override void OnRemove (int index, object value)
  94. {
  95. owner.Remove (value);
  96. }
  97. protected override void OnSet (int index, object oldValue, object newValue)
  98. {
  99. owner.Remove (oldValue);
  100. owner.Add (newValue);
  101. }
  102. public void Remove (EventLogPermissionEntry value)
  103. {
  104. List.Remove (value);
  105. }
  106. }
  107. }