/Mono.Cecil/CallSite.cs
C# | 106 lines | 75 code | 22 blank | 9 comment | 2 complexity | 956d5aa8fca9ef334860fa6cde1e777b 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; 13 14using Mono.Collections.Generic; 15 16namespace Mono.Cecil { 17 18 public sealed class CallSite : IMethodSignature { 19 20 readonly MethodReference signature; 21 22 public bool HasThis { 23 get { return signature.HasThis; } 24 set { signature.HasThis = value; } 25 } 26 27 public bool ExplicitThis { 28 get { return signature.ExplicitThis; } 29 set { signature.ExplicitThis = value; } 30 } 31 32 public MethodCallingConvention CallingConvention { 33 get { return signature.CallingConvention; } 34 set { signature.CallingConvention = value; } 35 } 36 37 public bool HasParameters { 38 get { return signature.HasParameters; } 39 } 40 41 public Collection<ParameterDefinition> Parameters { 42 get { return signature.Parameters; } 43 } 44 45 public TypeReference ReturnType { 46 get { return signature.MethodReturnType.ReturnType; } 47 set { signature.MethodReturnType.ReturnType = value; } 48 } 49 50 public MethodReturnType MethodReturnType { 51 get { return signature.MethodReturnType; } 52 } 53 54 public string Name { 55 get { return string.Empty; } 56 set { throw new InvalidOperationException (); } 57 } 58 59 public string Namespace { 60 get { return string.Empty; } 61 set { throw new InvalidOperationException (); } 62 } 63 64 public ModuleDefinition Module { 65 get { return ReturnType.Module; } 66 } 67 68 public IMetadataScope Scope { 69 get { return signature.ReturnType.Scope; } 70 } 71 72 public MetadataToken MetadataToken { 73 get { return signature.token; } 74 set { signature.token = value; } 75 } 76 77 public string FullName { 78 get { 79 var signature = new StringBuilder (); 80 signature.Append (ReturnType.FullName); 81 this.MethodSignatureFullName (signature); 82 return signature.ToString (); 83 } 84 } 85 86 internal CallSite () 87 { 88 this.signature = new MethodReference (); 89 this.signature.token = new MetadataToken (TokenType.Signature, 0); 90 } 91 92 public CallSite (TypeReference returnType) 93 : this () 94 { 95 if (returnType == null) 96 throw new ArgumentNullException ("returnType"); 97 98 this.signature.ReturnType = returnType; 99 } 100 101 public override string ToString () 102 { 103 return FullName; 104 } 105 } 106}