/Mono.Cecil/CallSite.cs

http://github.com/jbevain/cecil · 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. using System;
  11. using System.Text;
  12. using Mono.Collections.Generic;
  13. namespace Mono.Cecil {
  14. public sealed class CallSite : IMethodSignature {
  15. readonly MethodReference signature;
  16. public bool HasThis {
  17. get { return signature.HasThis; }
  18. set { signature.HasThis = value; }
  19. }
  20. public bool ExplicitThis {
  21. get { return signature.ExplicitThis; }
  22. set { signature.ExplicitThis = value; }
  23. }
  24. public MethodCallingConvention CallingConvention {
  25. get { return signature.CallingConvention; }
  26. set { signature.CallingConvention = value; }
  27. }
  28. public bool HasParameters {
  29. get { return signature.HasParameters; }
  30. }
  31. public Collection<ParameterDefinition> Parameters {
  32. get { return signature.Parameters; }
  33. }
  34. public TypeReference ReturnType {
  35. get { return signature.MethodReturnType.ReturnType; }
  36. set { signature.MethodReturnType.ReturnType = value; }
  37. }
  38. public MethodReturnType MethodReturnType {
  39. get { return signature.MethodReturnType; }
  40. }
  41. public string Name {
  42. get { return string.Empty; }
  43. set { throw new InvalidOperationException (); }
  44. }
  45. public string Namespace {
  46. get { return string.Empty; }
  47. set { throw new InvalidOperationException (); }
  48. }
  49. public ModuleDefinition Module {
  50. get { return ReturnType.Module; }
  51. }
  52. public IMetadataScope Scope {
  53. get { return signature.ReturnType.Scope; }
  54. }
  55. public MetadataToken MetadataToken {
  56. get { return signature.token; }
  57. set { signature.token = value; }
  58. }
  59. public string FullName {
  60. get {
  61. var signature = new StringBuilder ();
  62. signature.Append (ReturnType.FullName);
  63. this.MethodSignatureFullName (signature);
  64. return signature.ToString ();
  65. }
  66. }
  67. internal CallSite ()
  68. {
  69. this.signature = new MethodReference ();
  70. this.signature.token = new MetadataToken (TokenType.Signature, 0);
  71. }
  72. public CallSite (TypeReference returnType)
  73. : this ()
  74. {
  75. if (returnType == null)
  76. throw new ArgumentNullException ("returnType");
  77. this.signature.ReturnType = returnType;
  78. }
  79. public override string ToString ()
  80. {
  81. return FullName;
  82. }
  83. }
  84. }