Check.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //
  2. // Check.cs
  3. //
  4. // Author:
  5. // Jb Evain ([email protected])
  6. //
  7. // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. namespace System.Linq {
  30. static class Check {
  31. public static void Source (object source)
  32. {
  33. if (source == null)
  34. throw new ArgumentNullException ("source");
  35. }
  36. public static void Source1AndSource2 (object source1,object source2)
  37. {
  38. if (source1 == null)
  39. throw new ArgumentNullException ("source1");
  40. if (source2 == null)
  41. throw new ArgumentNullException ("source2");
  42. }
  43. public static void SourceAndFuncAndSelector ( object source, object func, object selector)
  44. {
  45. if (source == null)
  46. throw new ArgumentNullException ("source");
  47. if (func == null)
  48. throw new ArgumentNullException ("func");
  49. if (selector == null)
  50. throw new ArgumentNullException ("selector");
  51. }
  52. public static void SourceAndFunc (object source, object func)
  53. {
  54. if (source == null)
  55. throw new ArgumentNullException ("source");
  56. if (func == null)
  57. throw new ArgumentNullException ("func");
  58. }
  59. public static void SourceAndSelector (object source, object selector)
  60. {
  61. if (source == null)
  62. throw new ArgumentNullException ("source");
  63. if (selector == null)
  64. throw new ArgumentNullException ("selector");
  65. }
  66. public static void SourceAndPredicate (object source, object predicate)
  67. {
  68. if (source == null)
  69. throw new ArgumentNullException ("source");
  70. if (predicate == null)
  71. throw new ArgumentNullException ("predicate");
  72. }
  73. public static void FirstAndSecond (object first, object second)
  74. {
  75. if (first == null)
  76. throw new ArgumentNullException ("first");
  77. if (second == null)
  78. throw new ArgumentNullException ("second");
  79. }
  80. public static void SourceAndKeySelector (object source, object keySelector)
  81. {
  82. if (source == null)
  83. throw new ArgumentNullException ("source");
  84. if (keySelector == null)
  85. throw new ArgumentNullException ("keySelector");
  86. }
  87. public static void SourceAndKeyElementSelectors (object source, object keySelector, object elementSelector)
  88. {
  89. if (source == null)
  90. throw new ArgumentNullException ("source");
  91. if (keySelector == null)
  92. throw new ArgumentNullException ("keySelector");
  93. if (elementSelector == null)
  94. throw new ArgumentNullException ("elementSelector");
  95. }
  96. public static void SourceAndKeyResultSelectors (object source, object keySelector, object resultSelector)
  97. {
  98. if (source == null)
  99. throw new ArgumentNullException ("source");
  100. if (keySelector == null)
  101. throw new ArgumentNullException ("keySelector");
  102. if (resultSelector == null)
  103. throw new ArgumentNullException ("resultSelector");
  104. }
  105. public static void SourceAndCollectionSelectorAndResultSelector (object source, object collectionSelector, object resultSelector)
  106. {
  107. if (source == null)
  108. throw new ArgumentNullException ("source");
  109. if (collectionSelector == null)
  110. throw new ArgumentNullException ("collectionSelector");
  111. if (resultSelector == null)
  112. throw new ArgumentNullException ("resultSelector");
  113. }
  114. public static void SourceAndCollectionSelectors (object source, object collectionSelector, object selector)
  115. {
  116. if (source == null)
  117. throw new ArgumentNullException ("source");
  118. if (collectionSelector == null)
  119. throw new ArgumentNullException ("collectionSelector");
  120. if (selector == null)
  121. throw new ArgumentNullException ("selector");
  122. }
  123. public static void JoinSelectors (object outer, object inner, object outerKeySelector, object innerKeySelector, object resultSelector)
  124. {
  125. if (outer == null)
  126. throw new ArgumentNullException ("outer");
  127. if (inner == null)
  128. throw new ArgumentNullException ("inner");
  129. if (outerKeySelector == null)
  130. throw new ArgumentNullException ("outerKeySelector");
  131. if (innerKeySelector == null)
  132. throw new ArgumentNullException ("innerKeySelector");
  133. if (resultSelector == null)
  134. throw new ArgumentNullException ("resultSelector");
  135. }
  136. public static void GroupBySelectors (object source, object keySelector, object elementSelector, object resultSelector)
  137. {
  138. if (source == null)
  139. throw new ArgumentNullException ("source");
  140. if (keySelector == null)
  141. throw new ArgumentNullException ("keySelector");
  142. if (elementSelector == null)
  143. throw new ArgumentNullException ("elementSelector");
  144. if (resultSelector == null)
  145. throw new ArgumentNullException ("resultSelector");
  146. }
  147. }
  148. }