PageRenderTime 41ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/Tests/SpecialTestCases/OverloadedGenericMethodSignatures.cs

http://github.com/kevingadd/JSIL
C# | 53 lines | 43 code | 10 blank | 0 comment | 5 complexity | c7a83d981dd0854799e10f2d32edd489 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using JSIL;
  3. using JSIL.Meta;
  4. using System.Collections.Generic;
  5. public static class CommonExtensionMethodsSimple {
  6. public static bool Any<TSource> (this IEnumerable<TSource> source) {
  7. Console.WriteLine("Any with one argument");
  8. using (var enumerator = source.GetEnumerator())
  9. return enumerator.MoveNext();
  10. }
  11. public static bool Any<TSource> (this IEnumerable<TSource> source, Func<TSource, bool> predicate) {
  12. Console.WriteLine("Any with two arguments");
  13. foreach (TSource element in source)
  14. if (predicate(element))
  15. return true;
  16. return false;
  17. }
  18. public static bool IsNullOrEmpty<T> (this IEnumerable<T> items) {
  19. Console.WriteLine("IsNullOrEmpty with 1 parameters");
  20. return items == null || !items.Any();
  21. return true;
  22. }
  23. public static bool IsNullOrEmpty<T> (this IEnumerable<T> items, Func<T, bool> expression) {
  24. Console.WriteLine("IsNullOrEmpty with 2 parameters");
  25. return items == null || !items.Any(expression);
  26. return true;
  27. }
  28. public static bool IsNullOrEmpty(this string items)
  29. {
  30. Console.WriteLine("IsNullOrEmpty string");
  31. return String.IsNullOrEmpty(items);
  32. }
  33. }
  34. public static class Program {
  35. public static IEnumerable<string> GetSomeStrings () {
  36. yield return "aaaa";
  37. yield return "bbb";
  38. }
  39. public static void Main () {
  40. IEnumerable<string> en = GetSomeStrings();
  41. Console.WriteLine(en.IsNullOrEmpty() ? "true" : "false");
  42. }
  43. }