/Mono.Cecil/IMarshalInfoProvider.cs

http://github.com/jbevain/cecil · C# · 38 lines · 23 code · 6 blank · 9 comment · 1 complexity · fdf262e565d35c0a63aef9b3b40daecf 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 IMarshalInfoProvider : IMetadataTokenProvider {
  12. bool HasMarshalInfo { get; }
  13. MarshalInfo MarshalInfo { get; set; }
  14. }
  15. static partial class Mixin {
  16. public static bool GetHasMarshalInfo (
  17. this IMarshalInfoProvider self,
  18. ModuleDefinition module)
  19. {
  20. return module.HasImage () && module.Read (self, (provider, reader) => reader.HasMarshalInfo (provider));
  21. }
  22. public static MarshalInfo GetMarshalInfo (
  23. this IMarshalInfoProvider self,
  24. ref MarshalInfo variable,
  25. ModuleDefinition module)
  26. {
  27. return module.HasImage ()
  28. ? module.Read (ref variable, self, (provider, reader) => reader.ReadMarshalInfo (provider))
  29. : null;
  30. }
  31. }
  32. }