/Mono.Cecil/IGenericInstance.cs

http://github.com/jbevain/cecil · C# · 48 lines · 29 code · 10 blank · 9 comment · 4 complexity · d8513e35cc2ceeb0b7f2ef439502d762 MD5 · raw file

  1. //
  2. // Author:
  3. // Jb Evain (jbevain@gmail.com)
  4. //
  5. // Copyright (c) 2008 - 2015 Jb Evain
  6. // Copyright (c) 2008 - 2011 Novell, Inc.
  7. //
  8. // Licensed under the MIT/X11 license.
  9. //
  10. using System.Text;
  11. using Mono.Collections.Generic;
  12. namespace Mono.Cecil {
  13. public interface IGenericInstance : IMetadataTokenProvider {
  14. bool HasGenericArguments { get; }
  15. Collection<TypeReference> GenericArguments { get; }
  16. }
  17. static partial class Mixin {
  18. public static bool ContainsGenericParameter (this IGenericInstance self)
  19. {
  20. var arguments = self.GenericArguments;
  21. for (int i = 0; i < arguments.Count; i++)
  22. if (arguments [i].ContainsGenericParameter)
  23. return true;
  24. return false;
  25. }
  26. public static void GenericInstanceFullName (this IGenericInstance self, StringBuilder builder)
  27. {
  28. builder.Append ("<");
  29. var arguments = self.GenericArguments;
  30. for (int i = 0; i < arguments.Count; i++) {
  31. if (i > 0)
  32. builder.Append (",");
  33. builder.Append (arguments [i].FullName);
  34. }
  35. builder.Append (">");
  36. }
  37. }
  38. }