/Mono.Cecil/IMemberDefinition.cs

http://github.com/jbevain/cecil · C# · 82 lines · 55 code · 18 blank · 9 comment · 8 complexity · ca47041871947737fed78b0b2d627c4e 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. namespace Mono.Cecil {
  11. public interface IMemberDefinition : ICustomAttributeProvider {
  12. string Name { get; set; }
  13. string FullName { get; }
  14. bool IsSpecialName { get; set; }
  15. bool IsRuntimeSpecialName { get; set; }
  16. TypeDefinition DeclaringType { get; set; }
  17. }
  18. static partial class Mixin {
  19. public static bool GetAttributes (this uint self, uint attributes)
  20. {
  21. return (self & attributes) != 0;
  22. }
  23. public static uint SetAttributes (this uint self, uint attributes, bool value)
  24. {
  25. if (value)
  26. return self | attributes;
  27. return self & ~attributes;
  28. }
  29. public static bool GetMaskedAttributes (this uint self, uint mask, uint attributes)
  30. {
  31. return (self & mask) == attributes;
  32. }
  33. public static uint SetMaskedAttributes (this uint self, uint mask, uint attributes, bool value)
  34. {
  35. if (value) {
  36. self &= ~mask;
  37. return self | attributes;
  38. }
  39. return self & ~(mask & attributes);
  40. }
  41. public static bool GetAttributes (this ushort self, ushort attributes)
  42. {
  43. return (self & attributes) != 0;
  44. }
  45. public static ushort SetAttributes (this ushort self, ushort attributes, bool value)
  46. {
  47. if (value)
  48. return (ushort) (self | attributes);
  49. return (ushort) (self & ~attributes);
  50. }
  51. public static bool GetMaskedAttributes (this ushort self, ushort mask, uint attributes)
  52. {
  53. return (self & mask) == attributes;
  54. }
  55. public static ushort SetMaskedAttributes (this ushort self, ushort mask, uint attributes, bool value)
  56. {
  57. if (value) {
  58. self = (ushort) (self & ~mask);
  59. return (ushort) (self | attributes);
  60. }
  61. return (ushort) (self & ~(mask & attributes));
  62. }
  63. }
  64. }