ILRuntimeConstructorInfo.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Reflection;
  6. using System.Globalization;
  7. using ILRuntime.CLR.Method;
  8. using ILRuntime.CLR.TypeSystem;
  9. namespace ILRuntime.Reflection
  10. {
  11. public class ILRuntimeConstructorInfo : ConstructorInfo
  12. {
  13. ILMethod method;
  14. ILRuntimeParameterInfo[] parameters;
  15. public ILRuntimeConstructorInfo(ILMethod m)
  16. {
  17. method = m;
  18. parameters = new ILRuntimeParameterInfo[m.ParameterCount];
  19. for(int i = 0; i < m.ParameterCount; i++)
  20. {
  21. var pd = m.Definition.Parameters[i];
  22. parameters[i] = new ILRuntimeParameterInfo(pd, m.Parameters[i], this);
  23. }
  24. }
  25. internal ILMethod ILMethod { get { return method; } }
  26. public override MethodAttributes Attributes
  27. {
  28. get
  29. {
  30. return MethodAttributes.Public;
  31. }
  32. }
  33. public override Type DeclaringType
  34. {
  35. get
  36. {
  37. return method.DeclearingType.ReflectionType;
  38. }
  39. }
  40. public override RuntimeMethodHandle MethodHandle
  41. {
  42. get
  43. {
  44. throw new NotImplementedException();
  45. }
  46. }
  47. public override string Name
  48. {
  49. get
  50. {
  51. return method.Name;
  52. }
  53. }
  54. public override Type ReflectedType
  55. {
  56. get
  57. {
  58. return method.DeclearingType.ReflectionType;
  59. }
  60. }
  61. public override object[] GetCustomAttributes(bool inherit)
  62. {
  63. throw new NotImplementedException();
  64. }
  65. public override object[] GetCustomAttributes(Type attributeType, bool inherit)
  66. {
  67. throw new NotImplementedException();
  68. }
  69. public override MethodImplAttributes GetMethodImplementationFlags()
  70. {
  71. throw new NotImplementedException();
  72. }
  73. public override ParameterInfo[] GetParameters()
  74. {
  75. return parameters;
  76. }
  77. public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
  78. {
  79. var res = ((ILType)method.DeclearingType).Instantiate(false);
  80. method.DeclearingType.AppDomain.Invoke(method, res, parameters);
  81. return res;
  82. }
  83. public override bool IsDefined(Type attributeType, bool inherit)
  84. {
  85. throw new NotImplementedException();
  86. }
  87. public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
  88. {
  89. var res = ((ILType)method.DeclearingType).Instantiate(false);
  90. method.DeclearingType.AppDomain.Invoke(method, res, parameters);
  91. return res;
  92. }
  93. }
  94. }