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

/Mono.Cecil/GenericInstanceMethod.cs

http://github.com/jbevain/cecil
C# | 78 lines | 54 code | 15 blank | 9 comment | 3 complexity | 3c0c43c2e31cdab29d83bf8e5525e35c 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;
12using System.Text;
13using System.Threading;
14using Mono.Collections.Generic;
15
16namespace Mono.Cecil {
17
18	public sealed class GenericInstanceMethod : MethodSpecification, IGenericInstance, IGenericContext {
19
20		Collection<TypeReference> arguments;
21
22		public bool HasGenericArguments {
23			get { return !arguments.IsNullOrEmpty (); }
24		}
25
26		public Collection<TypeReference> GenericArguments {
27			get {
28				if (arguments == null)
29					Interlocked.CompareExchange (ref arguments, new Collection<TypeReference> (), null);
30
31				return arguments;
32			}
33		}
34
35		public override bool IsGenericInstance {
36			get { return true; }
37		}
38
39		IGenericParameterProvider IGenericContext.Method {
40			get { return ElementMethod; }
41		}
42
43		IGenericParameterProvider IGenericContext.Type {
44			get { return ElementMethod.DeclaringType; }
45		}
46
47		public override bool ContainsGenericParameter {
48			get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; }
49		}
50
51		public override string FullName {
52			get {
53				var signature = new StringBuilder ();
54				var method = this.ElementMethod;
55				signature.Append (method.ReturnType.FullName)
56					.Append (" ")
57					.Append (method.DeclaringType.FullName)
58					.Append ("::")
59					.Append (method.Name);
60				this.GenericInstanceFullName (signature);
61				this.MethodSignatureFullName (signature);
62				return signature.ToString ();
63
64			}
65		}
66
67		public GenericInstanceMethod (MethodReference method)
68			: base (method)
69		{
70		}
71
72		internal GenericInstanceMethod (MethodReference method, int arity)
73			: this (method)
74		{
75			this.arguments = new Collection<TypeReference> (arity);
76		}
77	}
78}