5
5
// Jb Evain (jbevain@gmail.com)
7
// Copyright (c) 2008 - 2010 Jb Evain
9
9
// Permission is hereby granted, free of charge, to any person obtaining
10
10
// a copy of this software and associated documentation files (the
26
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
33
namespace Mono.Cecil.Metadata {
32
using System.Collections;
34
public class GuidHeap : MetadataHeap {
36
readonly IDictionary m_guids;
38
public IDictionary Guids {
39
get { return m_guids; }
42
public GuidHeap (MetadataStream stream) : base (stream, MetadataStream.GUID)
44
int capacity = (int)(stream.Header.Size / 16);
45
m_guids = new Hashtable (capacity);
48
public Guid this [uint index] {
51
return new Guid (new byte [16]);
53
int idx = (int) index - 1;
55
if (m_guids.Contains (idx))
56
return (Guid) m_guids [idx];
58
if (idx + 16 > this.Data.Length)
59
throw new IndexOutOfRangeException ();
61
byte [] buffer = null;
62
if (this.Data.Length == 16) {
65
buffer = new byte [16];
66
Buffer.BlockCopy (this.Data, idx, buffer, 0, 16);
68
Guid res = new Guid (buffer);
72
set { m_guids [index] = value; }
75
public override void Accept (IMetadataVisitor visitor)
77
visitor.VisitGuidHeap (this);
35
sealed class GuidHeap : Heap {
37
public GuidHeap (Section section, uint start, uint size)
38
: base (section, start, size)
42
public Guid Read (uint index)
47
const int guid_size = 16;
49
var buffer = new byte [guid_size];
53
Buffer.BlockCopy (Section.Data, (int) (Offset + index), buffer, 0, guid_size);
55
return new Guid (buffer);