/Mono.Cecil.Metadata/GuidHeap.cs

http://github.com/jbevain/cecil · C# · 36 lines · 18 code · 9 blank · 9 comment · 3 complexity · 274135d903d9cee4d37f620bfa0d3907 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;
  11. namespace Mono.Cecil.Metadata {
  12. sealed class GuidHeap : Heap {
  13. public GuidHeap (byte [] data)
  14. : base (data)
  15. {
  16. }
  17. public Guid Read (uint index)
  18. {
  19. const int guid_size = 16;
  20. if (index == 0 || ((index - 1) + guid_size) > data.Length)
  21. return new Guid ();
  22. var buffer = new byte [guid_size];
  23. Buffer.BlockCopy (this.data, (int) ((index - 1) * guid_size), buffer, 0, guid_size);
  24. return new Guid (buffer);
  25. }
  26. }
  27. }