PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Mono.Cecil/ParameterDefinitionCollection.cs

http://github.com/jbevain/cecil
C# | 62 lines | 40 code | 13 blank | 9 comment | 2 complexity | 042ed63f7646a1877462807e4c5be15f 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
13using Mono.Collections.Generic;
14
15namespace Mono.Cecil {
16
17	sealed class ParameterDefinitionCollection : Collection<ParameterDefinition> {
18
19		readonly IMethodSignature method;
20
21		internal ParameterDefinitionCollection (IMethodSignature method)
22		{
23			this.method = method;
24		}
25
26		internal ParameterDefinitionCollection (IMethodSignature method, int capacity)
27			: base (capacity)
28		{
29			this.method = method;
30		}
31
32		protected override void OnAdd (ParameterDefinition item, int index)
33		{
34			item.method = method;
35			item.index = index;
36		}
37
38		protected override void OnInsert (ParameterDefinition item, int index)
39		{
40			item.method = method;
41			item.index = index;
42
43			for (int i = index; i < size; i++)
44				items [i].index = i + 1;
45		}
46
47		protected override void OnSet (ParameterDefinition item, int index)
48		{
49			item.method = method;
50			item.index = index;
51		}
52
53		protected override void OnRemove (ParameterDefinition item, int index)
54		{
55			item.method = null;
56			item.index = -1;
57
58			for (int i = index + 1; i < size; i++)
59				items [i].index = i - 1;
60		}
61	}
62}