~ubuntu-branches/ubuntu/trusty/mono-addins/trusty-proposed

« back to all changes in this revision

Viewing changes to Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-04-25 11:11:33 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110425111133-t05u5p7o5fxx70fu
Tags: 0.6-2
Upload to Unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
// Author:
5
5
//   Jb Evain (jbevain@gmail.com)
6
6
//
7
 
// Generated by /CodeGen/cecil-gen.rb do not edit
8
 
// Wed Sep 27 12:46:52 CEST 2006
9
 
//
10
 
// (C) 2005 Jb Evain
 
7
// Copyright (c) 2008 - 2010 Jb Evain
11
8
//
12
9
// Permission is hereby granted, free of charge, to any person obtaining
13
10
// a copy of this software and associated documentation files (the
29
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
27
//
31
28
 
 
29
using System;
 
30
 
 
31
using Mono.Collections.Generic;
 
32
 
32
33
namespace Mono.Cecil {
33
34
 
34
 
        using System;
35
 
        using System.Collections;
36
 
 
37
 
        using Mono.Cecil.Cil;
38
 
 
39
 
        public sealed class ParameterDefinitionCollection : CollectionBase, IReflectionVisitable {
40
 
 
41
 
                IMemberReference m_container;
42
 
 
43
 
                public ParameterDefinition this [int index] {
44
 
                        get { return List [index] as ParameterDefinition; }
45
 
                        set { List [index] = value; }
46
 
                }
47
 
 
48
 
                public IMemberReference Container {
49
 
                        get { return m_container; }
50
 
                }
51
 
 
52
 
                public ParameterDefinitionCollection (IMemberReference container)
53
 
                {
54
 
                        m_container = container;
55
 
                }
56
 
 
57
 
                public void Add (ParameterDefinition value)
58
 
                {
59
 
                        List.Add (value);
60
 
                }
61
 
 
62
 
                public bool Contains (ParameterDefinition value)
63
 
                {
64
 
                        return List.Contains (value);
65
 
                }
66
 
 
67
 
                public int IndexOf (ParameterDefinition value)
68
 
                {
69
 
                        return List.IndexOf (value);
70
 
                }
71
 
 
72
 
                public void Insert (int index, ParameterDefinition value)
73
 
                {
74
 
                        List.Insert (index, value);
75
 
                }
76
 
 
77
 
                public void Remove (ParameterDefinition value)
78
 
                {
79
 
                        List.Remove (value);
80
 
                }
81
 
 
82
 
                protected override void OnValidate (object o)
83
 
                {
84
 
                        if (! (o is ParameterDefinition))
85
 
                                throw new ArgumentException ("Must be of type " + typeof (ParameterDefinition).FullName);
86
 
                }
87
 
 
88
 
                public void Accept (IReflectionVisitor visitor)
89
 
                {
90
 
                        visitor.VisitParameterDefinitionCollection (this);
 
35
        sealed class ParameterDefinitionCollection : Collection<ParameterDefinition> {
 
36
 
 
37
                readonly IMethodSignature method;
 
38
 
 
39
                internal ParameterDefinitionCollection (IMethodSignature method)
 
40
                {
 
41
                        this.method = method;
 
42
                }
 
43
 
 
44
                internal ParameterDefinitionCollection (IMethodSignature method, int capacity)
 
45
                        : base (capacity)
 
46
                {
 
47
                        this.method = method;
 
48
                }
 
49
 
 
50
                protected override void OnAdd (ParameterDefinition item, int index)
 
51
                {
 
52
                        item.method = method;
 
53
                        item.index = index;
 
54
                }
 
55
 
 
56
                protected override void OnInsert (ParameterDefinition item, int index)
 
57
                {
 
58
                        item.method = method;
 
59
                        item.index = index;
 
60
 
 
61
                        for (int i = index; i < size; i++)
 
62
                                items [i].index = i + 1;
 
63
                }
 
64
 
 
65
                protected override void OnSet (ParameterDefinition item, int index)
 
66
                {
 
67
                        item.method = method;
 
68
                        item.index = index;
 
69
                }
 
70
 
 
71
                protected override void OnRemove (ParameterDefinition item, int index)
 
72
                {
 
73
                        item.method = null;
 
74
                        item.index = -1;
 
75
 
 
76
                        for (int i = index + 1; i < size; i++)
 
77
                                items [i].index = i - 1;
91
78
                }
92
79
        }
93
80
}