PageRenderTime 21ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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
11using System;
12
13namespace Mono.Cecil.Metadata {
14
15	sealed class GuidHeap : Heap {
16
17		public GuidHeap (byte [] data)
18			: base (data)
19		{
20		}
21
22		public Guid Read (uint index)
23		{
24			const int guid_size = 16;
25
26			if (index == 0 || ((index - 1) + guid_size) > data.Length)
27				return new Guid ();
28
29			var buffer = new byte [guid_size];
30
31			Buffer.BlockCopy (this.data, (int) ((index - 1) * guid_size), buffer, 0, guid_size);
32
33			return new Guid (buffer);
34		}
35	}
36}